trunk/src/emu/cpu/mips/mips3com.c
| r30757 | r30758 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /*************************************************************************** |
| 16 | | DEBUGGING |
| 17 | | ***************************************************************************/ |
| 18 | | |
| 19 | | #define PRINTF_TLB (0) |
| 20 | | #define USE_ABI_REG_NAMES (1) |
| 21 | | |
| 22 | | |
| 23 | | /*************************************************************************** |
| 24 | 16 | FUNCTION PROTOTYPES |
| 25 | 17 | ***************************************************************************/ |
| 26 | 18 | |
| 27 | | static TIMER_CALLBACK( compare_int_callback ); |
| 28 | | |
| 29 | | static UINT32 compute_config_register(const mips3_state *mips); |
| 30 | | static UINT32 compute_prid_register(const mips3_state *mips); |
| 31 | | |
| 32 | | static void tlb_map_entry(mips3_state *mips, int tlbindex); |
| 33 | | static void tlb_write_common(mips3_state *mips, int tlbindex); |
| 34 | 19 | static void tlb_entry_log_half(mips3_tlb_entry *entry, int tlbindex, int which); |
| 35 | 20 | |
| 36 | 21 | |
| r30757 | r30758 | |
| 61 | 46 | } |
| 62 | 47 | |
| 63 | 48 | |
| 64 | | |
| 65 | | /*************************************************************************** |
| 66 | | INITIALIZATION AND SHUTDOWN |
| 67 | | ***************************************************************************/ |
| 68 | | |
| 69 | | /*------------------------------------------------- |
| 70 | | mips3com_init - initialize the mips3_state |
| 71 | | structure based on the configured type |
| 72 | | -------------------------------------------------*/ |
| 73 | | |
| 74 | | void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, legacy_cpu_device *device, device_irq_acknowledge_delegate irqcallback) |
| 49 | void mips3_device::execute_set_input(int inputnum, int state) |
| 75 | 50 | { |
| 76 | | const mips3_config *config = (const mips3_config *)device->static_config(); |
| 77 | | int tlbindex; |
| 78 | | |
| 79 | | /* initialize based on the config */ |
| 80 | | memset(mips, 0, sizeof(*mips)); |
| 81 | | mips->flavor = flavor; |
| 82 | | mips->bigendian = bigendian; |
| 83 | | mips->cpu_clock = device->clock(); |
| 84 | | mips->irq_callback = irqcallback; |
| 85 | | mips->device = device; |
| 86 | | mips->program = &device->space(AS_PROGRAM); |
| 87 | | mips->direct = &mips->program->direct(); |
| 88 | | mips->icache_size = config->icache; |
| 89 | | mips->dcache_size = config->dcache; |
| 90 | | mips->system_clock = config->system_clock; |
| 91 | | |
| 92 | | /* configure flavor-specific parameters */ |
| 93 | | mips->pfnmask = 0x00ffffff; |
| 94 | | mips->tlbentries = MIPS3_MAX_TLB_ENTRIES; |
| 95 | | |
| 96 | | /* VR4300 and VR5432 have 4 fewer PFN bits, and only 32 TLB entries */ |
| 97 | | if (flavor == MIPS3_TYPE_VR4300) |
| 51 | if (inputnum >= MIPS3_IRQ0 && inputnum <= MIPS3_IRQ5) |
| 98 | 52 | { |
| 99 | | mips->pfnmask = 0x000fffff; |
| 100 | | mips->tlbentries = 32; |
| 53 | if (state != CLEAR_LINE) |
| 54 | m_core->cpr[0][COP0_Cause] |= 0x400 << inputnum; |
| 55 | else |
| 56 | m_core->cpr[0][COP0_Cause] &= ~(0x400 << inputnum); |
| 101 | 57 | } |
| 102 | | |
| 103 | | /* set up the endianness */ |
| 104 | | mips->program->accessors(mips->memory); |
| 105 | | |
| 106 | | /* allocate the virtual TLB */ |
| 107 | | mips->vtlb = vtlb_alloc(device, AS_PROGRAM, 2 * mips->tlbentries + 2, 0); |
| 108 | | |
| 109 | | /* allocate a timer for the compare interrupt */ |
| 110 | | mips->compare_int_timer = device->machine().scheduler().timer_alloc(FUNC(compare_int_callback), (void *)device); |
| 111 | | |
| 112 | | /* reset the state */ |
| 113 | | mips3com_reset(mips); |
| 114 | | |
| 115 | | /* register for save states */ |
| 116 | | device->save_item(NAME(mips->pc)); |
| 117 | | device->save_item(NAME(mips->r)); |
| 118 | | device->save_item(NAME(mips->cpr)); |
| 119 | | device->save_item(NAME(mips->ccr)); |
| 120 | | device->save_item(NAME(mips->llbit)); |
| 121 | | device->save_item(NAME(mips->count_zero_time)); |
| 122 | | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 123 | | { |
| 124 | | device->save_item(NAME(mips->tlb[tlbindex].page_mask), tlbindex); |
| 125 | | device->save_item(NAME(mips->tlb[tlbindex].entry_hi), tlbindex); |
| 126 | | device->save_item(NAME(mips->tlb[tlbindex].entry_lo), tlbindex); |
| 127 | | } |
| 128 | 58 | } |
| 129 | 59 | |
| 130 | 60 | |
| 131 | | /*------------------------------------------------- |
| 132 | | mips3com_exit - common cleanup/exit |
| 133 | | -------------------------------------------------*/ |
| 61 | /*************************************************************************** |
| 62 | INITIALIZATION AND SHUTDOWN |
| 63 | ***************************************************************************/ |
| 134 | 64 | |
| 135 | | void mips3com_exit(mips3_state *mips) |
| 136 | | { |
| 137 | | if (mips->vtlb != NULL) |
| 138 | | vtlb_free(mips->vtlb); |
| 139 | | } |
| 140 | | |
| 141 | | |
| 142 | 65 | /*------------------------------------------------- |
| 143 | | mips3com_reset - reset the state of all the |
| 144 | | registers |
| 145 | | -------------------------------------------------*/ |
| 146 | | |
| 147 | | void mips3com_reset(mips3_state *mips) |
| 148 | | { |
| 149 | | int tlbindex; |
| 150 | | |
| 151 | | /* initialize the state */ |
| 152 | | mips->pc = 0xbfc00000; |
| 153 | | mips->cpr[0][COP0_Status] = SR_BEV | SR_ERL; |
| 154 | | mips->cpr[0][COP0_Wired] = 0; |
| 155 | | mips->cpr[0][COP0_Compare] = 0xffffffff; |
| 156 | | mips->cpr[0][COP0_Count] = 0; |
| 157 | | mips->cpr[0][COP0_Config] = compute_config_register(mips); |
| 158 | | mips->cpr[0][COP0_PRId] = compute_prid_register(mips); |
| 159 | | mips->count_zero_time = mips->device->total_cycles(); |
| 160 | | |
| 161 | | /* initialize the TLB state */ |
| 162 | | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 163 | | { |
| 164 | | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 165 | | entry->page_mask = 0; |
| 166 | | entry->entry_hi = 0xffffffff; |
| 167 | | entry->entry_lo[0] = 0xfffffff8; |
| 168 | | entry->entry_lo[1] = 0xfffffff8; |
| 169 | | vtlb_load(mips->vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 170 | | vtlb_load(mips->vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 171 | | } |
| 172 | | |
| 173 | | /* load the fixed TLB range */ |
| 174 | | vtlb_load(mips->vtlb, 2 * mips->tlbentries + 0, (0xa0000000 - 0x80000000) >> MIPS3_MIN_PAGE_SHIFT, 0x80000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID); |
| 175 | | vtlb_load(mips->vtlb, 2 * mips->tlbentries + 1, (0xc0000000 - 0xa0000000) >> MIPS3_MIN_PAGE_SHIFT, 0xa0000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID); |
| 176 | | } |
| 177 | | |
| 178 | | |
| 179 | | /*------------------------------------------------- |
| 180 | | mips3com_dasm - handle disassembly for a |
| 181 | | CPU |
| 182 | | -------------------------------------------------*/ |
| 183 | | |
| 184 | | offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) |
| 185 | | { |
| 186 | | extern unsigned dasmmips3(char *, unsigned, UINT32); |
| 187 | | UINT32 op = *(UINT32 *)oprom; |
| 188 | | if (mips->bigendian) |
| 189 | | op = BIG_ENDIANIZE_INT32(op); |
| 190 | | else |
| 191 | | op = LITTLE_ENDIANIZE_INT32(op); |
| 192 | | return dasmmips3(buffer, pc, op); |
| 193 | | } |
| 194 | | |
| 195 | | |
| 196 | | /*------------------------------------------------- |
| 197 | 66 | mips3com_update_cycle_counting - update cycle |
| 198 | 67 | counts and the timers |
| 199 | 68 | -------------------------------------------------*/ |
| 200 | 69 | |
| 201 | | void mips3com_update_cycle_counting(mips3_state *mips) |
| 70 | void mips3_device::mips3com_update_cycle_counting() |
| 202 | 71 | { |
| 203 | 72 | /* modify the timer to go off */ |
| 204 | | if (mips->compare_armed && (mips->cpr[0][COP0_Status] & SR_IMEX5)) |
| 73 | if (m_core->compare_armed && (m_core->cpr[0][COP0_Status] & SR_IMEX5)) |
| 205 | 74 | { |
| 206 | | UINT32 count = (mips->device->total_cycles() - mips->count_zero_time) / 2; |
| 207 | | UINT32 compare = mips->cpr[0][COP0_Compare]; |
| 75 | UINT32 count = (total_cycles() - m_core->count_zero_time) / 2; |
| 76 | UINT32 compare = m_core->cpr[0][COP0_Compare]; |
| 208 | 77 | UINT32 delta = compare - count; |
| 209 | | attotime newtime = mips->device->cycles_to_attotime((UINT64)delta * 2); |
| 210 | | mips->compare_int_timer->adjust(newtime); |
| 78 | attotime newtime = cycles_to_attotime((UINT64)delta * 2); |
| 79 | m_compare_int_timer->adjust(newtime); |
| 211 | 80 | return; |
| 212 | 81 | } |
| 213 | | mips->compare_int_timer->adjust(attotime::never); |
| 82 | m_compare_int_timer->adjust(attotime::never); |
| 214 | 83 | } |
| 215 | 84 | |
| 216 | 85 | |
| r30757 | r30758 | |
| 224 | 93 | TLB entries |
| 225 | 94 | -------------------------------------------------*/ |
| 226 | 95 | |
| 227 | | void mips3com_asid_changed(mips3_state *mips) |
| 96 | void mips3_device::mips3com_asid_changed() |
| 228 | 97 | { |
| 229 | 98 | int tlbindex; |
| 230 | 99 | |
| 231 | 100 | /* iterate over all non-global TLB entries and remap them */ |
| 232 | | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 233 | | if (!tlb_entry_is_global(&mips->tlb[tlbindex])) |
| 234 | | tlb_map_entry(mips, tlbindex); |
| 101 | for (tlbindex = 0; tlbindex < m_tlbentries; tlbindex++) |
| 102 | if (!tlb_entry_is_global(&m_tlb[tlbindex])) |
| 103 | tlb_map_entry(tlbindex); |
| 235 | 104 | } |
| 236 | 105 | |
| 237 | 106 | |
| 238 | 107 | /*------------------------------------------------- |
| 239 | | mips3com_translate_address - translate an address |
| 240 | | from logical to physical |
| 241 | | -------------------------------------------------*/ |
| 242 | | |
| 243 | | int mips3com_translate_address(mips3_state *mips, address_spacenum space, int intention, offs_t *address) |
| 244 | | { |
| 245 | | /* only applies to the program address space */ |
| 246 | | if (space == AS_PROGRAM) |
| 247 | | { |
| 248 | | const vtlb_entry *table = vtlb_table(mips->vtlb); |
| 249 | | vtlb_entry entry = table[*address >> MIPS3_MIN_PAGE_SHIFT]; |
| 250 | | if ((entry & (1 << (intention & (TRANSLATE_TYPE_MASK | TRANSLATE_USER_MASK)))) == 0) |
| 251 | | return FALSE; |
| 252 | | *address = (entry & ~MIPS3_MIN_PAGE_MASK) | (*address & MIPS3_MIN_PAGE_MASK); |
| 253 | | } |
| 254 | | return TRUE; |
| 255 | | } |
| 256 | | |
| 257 | | |
| 258 | | /*------------------------------------------------- |
| 259 | 108 | mips3com_tlbr - execute the tlbr instruction |
| 260 | 109 | -------------------------------------------------*/ |
| 261 | 110 | |
| 262 | | void mips3com_tlbr(mips3_state *mips) |
| 111 | void mips3_device::mips3com_tlbr() |
| 263 | 112 | { |
| 264 | | UINT32 tlbindex = mips->cpr[0][COP0_Index] & 0x3f; |
| 113 | UINT32 tlbindex = m_core->cpr[0][COP0_Index] & 0x3f; |
| 265 | 114 | |
| 266 | 115 | /* only handle entries within the TLB */ |
| 267 | | if (tlbindex < mips->tlbentries) |
| 116 | if (tlbindex < m_tlbentries) |
| 268 | 117 | { |
| 269 | | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 118 | mips3_tlb_entry *entry = &m_tlb[tlbindex]; |
| 270 | 119 | |
| 271 | 120 | /* copy data from the TLB entry into the COP0 registers */ |
| 272 | | mips->cpr[0][COP0_PageMask] = entry->page_mask; |
| 273 | | mips->cpr[0][COP0_EntryHi] = entry->entry_hi; |
| 274 | | mips->cpr[0][COP0_EntryLo0] = entry->entry_lo[0]; |
| 275 | | mips->cpr[0][COP0_EntryLo1] = entry->entry_lo[1]; |
| 121 | m_core->cpr[0][COP0_PageMask] = entry->page_mask; |
| 122 | m_core->cpr[0][COP0_EntryHi] = entry->entry_hi; |
| 123 | m_core->cpr[0][COP0_EntryLo0] = entry->entry_lo[0]; |
| 124 | m_core->cpr[0][COP0_EntryLo1] = entry->entry_lo[1]; |
| 276 | 125 | } |
| 277 | 126 | } |
| 278 | 127 | |
| r30757 | r30758 | |
| 281 | 130 | mips3com_tlbwi - execute the tlbwi instruction |
| 282 | 131 | -------------------------------------------------*/ |
| 283 | 132 | |
| 284 | | void mips3com_tlbwi(mips3_state *mips) |
| 133 | void mips3_device::mips3com_tlbwi() |
| 285 | 134 | { |
| 286 | 135 | /* use the common handler and write based off the COP0 Index register */ |
| 287 | | tlb_write_common(mips, mips->cpr[0][COP0_Index] & 0x3f); |
| 136 | tlb_write_common(m_core->cpr[0][COP0_Index] & 0x3f); |
| 288 | 137 | } |
| 289 | 138 | |
| 290 | 139 | |
| r30757 | r30758 | |
| 292 | 141 | mips3com_tlbwr - execute the tlbwr instruction |
| 293 | 142 | -------------------------------------------------*/ |
| 294 | 143 | |
| 295 | | void mips3com_tlbwr(mips3_state *mips) |
| 144 | void mips3_device::mips3com_tlbwr() |
| 296 | 145 | { |
| 297 | | UINT32 wired = mips->cpr[0][COP0_Wired] & 0x3f; |
| 298 | | UINT32 unwired = mips->tlbentries - wired; |
| 299 | | UINT32 tlbindex = mips->tlbentries - 1; |
| 146 | UINT32 wired = m_core->cpr[0][COP0_Wired] & 0x3f; |
| 147 | UINT32 unwired = m_tlbentries - wired; |
| 148 | UINT32 tlbindex = m_tlbentries - 1; |
| 300 | 149 | |
| 301 | 150 | /* "random" is based off of the current cycle counting through the non-wired pages */ |
| 302 | 151 | if (unwired > 0) |
| 303 | | tlbindex = ((mips->device->total_cycles() - mips->count_zero_time) % unwired + wired) & 0x3f; |
| 152 | tlbindex = ((total_cycles() - m_core->count_zero_time) % unwired + wired) & 0x3f; |
| 304 | 153 | |
| 305 | 154 | /* use the common handler to write to this tlbindex */ |
| 306 | | tlb_write_common(mips, tlbindex); |
| 155 | tlb_write_common(tlbindex); |
| 307 | 156 | } |
| 308 | 157 | |
| 309 | 158 | |
| r30757 | r30758 | |
| 311 | 160 | mips3com_tlbp - execute the tlbp instruction |
| 312 | 161 | -------------------------------------------------*/ |
| 313 | 162 | |
| 314 | | void mips3com_tlbp(mips3_state *mips) |
| 163 | void mips3_device::mips3com_tlbp() |
| 315 | 164 | { |
| 316 | 165 | UINT32 tlbindex; |
| 317 | | // UINT64 vpn; |
| 318 | 166 | |
| 319 | 167 | /* iterate over TLB entries */ |
| 320 | | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 168 | for (tlbindex = 0; tlbindex < m_tlbentries; tlbindex++) |
| 321 | 169 | { |
| 322 | | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 170 | mips3_tlb_entry *entry = &m_tlb[tlbindex]; |
| 323 | 171 | UINT64 mask = ~((entry->page_mask >> 13) & 0xfff) << 13; |
| 324 | 172 | |
| 325 | 173 | /* if the relevant bits of EntryHi match the relevant bits of the TLB */ |
| 326 | | if ((entry->entry_hi & mask) == (mips->cpr[0][COP0_EntryHi] & mask)) |
| 174 | if ((entry->entry_hi & mask) == (m_core->cpr[0][COP0_EntryHi] & mask)) |
| 327 | 175 | |
| 328 | 176 | /* and if we are either global or matching the current ASID, then stop */ |
| 329 | | if ((entry->entry_hi & 0xff) == (mips->cpr[0][COP0_EntryHi] & 0xff) || ((entry->entry_lo[0] & entry->entry_lo[1]) & TLB_GLOBAL)) |
| 177 | if ((entry->entry_hi & 0xff) == (m_core->cpr[0][COP0_EntryHi] & 0xff) || ((entry->entry_lo[0] & entry->entry_lo[1]) & TLB_GLOBAL)) |
| 330 | 178 | break; |
| 331 | 179 | } |
| 332 | 180 | |
| 333 | 181 | /* validate that our tlb_table was in sync */ |
| 334 | | // vpn = ((mips->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1; |
| 335 | | if (tlbindex != mips->tlbentries) |
| 336 | | mips->cpr[0][COP0_Index] = tlbindex; |
| 182 | // vpn = ((m_cores->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1; |
| 183 | if (tlbindex != m_tlbentries) |
| 184 | m_core->cpr[0][COP0_Index] = tlbindex; |
| 337 | 185 | else |
| 338 | | mips->cpr[0][COP0_Index] = 0x80000000; |
| 186 | m_core->cpr[0][COP0_Index] = 0x80000000; |
| 339 | 187 | } |
| 340 | 188 | |
| 341 | 189 | |
| 342 | 190 | |
| 343 | 191 | /*************************************************************************** |
| 344 | | COMMON GET/SET INFO |
| 345 | | ***************************************************************************/ |
| 346 | | |
| 347 | | /*------------------------------------------------- |
| 348 | | mips3com_set_info - set information about |
| 349 | | a MIPS 3 CPU |
| 350 | | -------------------------------------------------*/ |
| 351 | | |
| 352 | | void mips3com_set_info(mips3_state *mips, UINT32 state, cpuinfo *info) |
| 353 | | { |
| 354 | | switch (state) |
| 355 | | { |
| 356 | | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 357 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ0: mips3com_set_irq_line(mips, MIPS3_IRQ0, info->i); break; |
| 358 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ1: mips3com_set_irq_line(mips, MIPS3_IRQ1, info->i); break; |
| 359 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ2: mips3com_set_irq_line(mips, MIPS3_IRQ2, info->i); break; |
| 360 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ3: mips3com_set_irq_line(mips, MIPS3_IRQ3, info->i); break; |
| 361 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ4: mips3com_set_irq_line(mips, MIPS3_IRQ4, info->i); break; |
| 362 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ5: mips3com_set_irq_line(mips, MIPS3_IRQ5, info->i); break; |
| 363 | | |
| 364 | | case CPUINFO_INT_PC: |
| 365 | | case CPUINFO_INT_REGISTER + MIPS3_PC: mips->pc = info->i; break; |
| 366 | | case CPUINFO_INT_REGISTER + MIPS3_SR: mips->cpr[0][COP0_Status] = info->i; break; |
| 367 | | case CPUINFO_INT_REGISTER + MIPS3_EPC: mips->cpr[0][COP0_EPC] = info->i; break; |
| 368 | | case CPUINFO_INT_REGISTER + MIPS3_CAUSE: mips->cpr[0][COP0_Cause] = info->i; break; |
| 369 | | case CPUINFO_INT_REGISTER + MIPS3_COUNT: mips->cpr[0][COP0_Count] = info->i; break; |
| 370 | | case CPUINFO_INT_REGISTER + MIPS3_COMPARE: mips->cpr[0][COP0_Compare] = info->i; break; |
| 371 | | case CPUINFO_INT_REGISTER + MIPS3_INDEX: mips->cpr[0][COP0_Index] = info->i; break; |
| 372 | | case CPUINFO_INT_REGISTER + MIPS3_RANDOM: mips->cpr[0][COP0_Random] = info->i; break; |
| 373 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYHI: mips->cpr[0][COP0_EntryHi] = info->i; break; |
| 374 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYLO0: mips->cpr[0][COP0_EntryLo0] = info->i; break; |
| 375 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYLO1: mips->cpr[0][COP0_EntryLo1] = info->i; break; |
| 376 | | case CPUINFO_INT_REGISTER + MIPS3_PAGEMASK: mips->cpr[0][COP0_PageMask] = info->i; break; |
| 377 | | case CPUINFO_INT_REGISTER + MIPS3_WIRED: mips->cpr[0][COP0_Wired] = info->i; break; |
| 378 | | case CPUINFO_INT_REGISTER + MIPS3_BADVADDR: mips->cpr[0][COP0_BadVAddr] = info->i; break; |
| 379 | | |
| 380 | | case CPUINFO_INT_REGISTER + MIPS3_R0: /* can't change R0 */ break; |
| 381 | | case CPUINFO_INT_REGISTER + MIPS3_R1: mips->r[1] = info->i; break; |
| 382 | | case CPUINFO_INT_REGISTER + MIPS3_R2: mips->r[2] = info->i; break; |
| 383 | | case CPUINFO_INT_REGISTER + MIPS3_R3: mips->r[3] = info->i; break; |
| 384 | | case CPUINFO_INT_REGISTER + MIPS3_R4: mips->r[4] = info->i; break; |
| 385 | | case CPUINFO_INT_REGISTER + MIPS3_R5: mips->r[5] = info->i; break; |
| 386 | | case CPUINFO_INT_REGISTER + MIPS3_R6: mips->r[6] = info->i; break; |
| 387 | | case CPUINFO_INT_REGISTER + MIPS3_R7: mips->r[7] = info->i; break; |
| 388 | | case CPUINFO_INT_REGISTER + MIPS3_R8: mips->r[8] = info->i; break; |
| 389 | | case CPUINFO_INT_REGISTER + MIPS3_R9: mips->r[9] = info->i; break; |
| 390 | | case CPUINFO_INT_REGISTER + MIPS3_R10: mips->r[10] = info->i; break; |
| 391 | | case CPUINFO_INT_REGISTER + MIPS3_R11: mips->r[11] = info->i; break; |
| 392 | | case CPUINFO_INT_REGISTER + MIPS3_R12: mips->r[12] = info->i; break; |
| 393 | | case CPUINFO_INT_REGISTER + MIPS3_R13: mips->r[13] = info->i; break; |
| 394 | | case CPUINFO_INT_REGISTER + MIPS3_R14: mips->r[14] = info->i; break; |
| 395 | | case CPUINFO_INT_REGISTER + MIPS3_R15: mips->r[15] = info->i; break; |
| 396 | | case CPUINFO_INT_REGISTER + MIPS3_R16: mips->r[16] = info->i; break; |
| 397 | | case CPUINFO_INT_REGISTER + MIPS3_R17: mips->r[17] = info->i; break; |
| 398 | | case CPUINFO_INT_REGISTER + MIPS3_R18: mips->r[18] = info->i; break; |
| 399 | | case CPUINFO_INT_REGISTER + MIPS3_R19: mips->r[19] = info->i; break; |
| 400 | | case CPUINFO_INT_REGISTER + MIPS3_R20: mips->r[20] = info->i; break; |
| 401 | | case CPUINFO_INT_REGISTER + MIPS3_R21: mips->r[21] = info->i; break; |
| 402 | | case CPUINFO_INT_REGISTER + MIPS3_R22: mips->r[22] = info->i; break; |
| 403 | | case CPUINFO_INT_REGISTER + MIPS3_R23: mips->r[23] = info->i; break; |
| 404 | | case CPUINFO_INT_REGISTER + MIPS3_R24: mips->r[24] = info->i; break; |
| 405 | | case CPUINFO_INT_REGISTER + MIPS3_R25: mips->r[25] = info->i; break; |
| 406 | | case CPUINFO_INT_REGISTER + MIPS3_R26: mips->r[26] = info->i; break; |
| 407 | | case CPUINFO_INT_REGISTER + MIPS3_R27: mips->r[27] = info->i; break; |
| 408 | | case CPUINFO_INT_REGISTER + MIPS3_R28: mips->r[28] = info->i; break; |
| 409 | | case CPUINFO_INT_REGISTER + MIPS3_R29: mips->r[29] = info->i; break; |
| 410 | | case CPUINFO_INT_REGISTER + MIPS3_R30: mips->r[30] = info->i; break; |
| 411 | | case CPUINFO_INT_SP: |
| 412 | | case CPUINFO_INT_REGISTER + MIPS3_R31: mips->r[31] = info->i; break; |
| 413 | | case CPUINFO_INT_REGISTER + MIPS3_HI: mips->r[REG_HI] = info->i; break; |
| 414 | | case CPUINFO_INT_REGISTER + MIPS3_LO: mips->r[REG_LO] = info->i; break; |
| 415 | | |
| 416 | | case CPUINFO_INT_REGISTER + MIPS3_FPR0: mips->cpr[1][0] = info->i; break; |
| 417 | | case CPUINFO_INT_REGISTER + MIPS3_FPR1: mips->cpr[1][1] = info->i; break; |
| 418 | | case CPUINFO_INT_REGISTER + MIPS3_FPR2: mips->cpr[1][2] = info->i; break; |
| 419 | | case CPUINFO_INT_REGISTER + MIPS3_FPR3: mips->cpr[1][3] = info->i; break; |
| 420 | | case CPUINFO_INT_REGISTER + MIPS3_FPR4: mips->cpr[1][4] = info->i; break; |
| 421 | | case CPUINFO_INT_REGISTER + MIPS3_FPR5: mips->cpr[1][5] = info->i; break; |
| 422 | | case CPUINFO_INT_REGISTER + MIPS3_FPR6: mips->cpr[1][6] = info->i; break; |
| 423 | | case CPUINFO_INT_REGISTER + MIPS3_FPR7: mips->cpr[1][7] = info->i; break; |
| 424 | | case CPUINFO_INT_REGISTER + MIPS3_FPR8: mips->cpr[1][8] = info->i; break; |
| 425 | | case CPUINFO_INT_REGISTER + MIPS3_FPR9: mips->cpr[1][9] = info->i; break; |
| 426 | | case CPUINFO_INT_REGISTER + MIPS3_FPR10: mips->cpr[1][10] = info->i; break; |
| 427 | | case CPUINFO_INT_REGISTER + MIPS3_FPR11: mips->cpr[1][11] = info->i; break; |
| 428 | | case CPUINFO_INT_REGISTER + MIPS3_FPR12: mips->cpr[1][12] = info->i; break; |
| 429 | | case CPUINFO_INT_REGISTER + MIPS3_FPR13: mips->cpr[1][13] = info->i; break; |
| 430 | | case CPUINFO_INT_REGISTER + MIPS3_FPR14: mips->cpr[1][14] = info->i; break; |
| 431 | | case CPUINFO_INT_REGISTER + MIPS3_FPR15: mips->cpr[1][15] = info->i; break; |
| 432 | | case CPUINFO_INT_REGISTER + MIPS3_FPR16: mips->cpr[1][16] = info->i; break; |
| 433 | | case CPUINFO_INT_REGISTER + MIPS3_FPR17: mips->cpr[1][17] = info->i; break; |
| 434 | | case CPUINFO_INT_REGISTER + MIPS3_FPR18: mips->cpr[1][18] = info->i; break; |
| 435 | | case CPUINFO_INT_REGISTER + MIPS3_FPR19: mips->cpr[1][19] = info->i; break; |
| 436 | | case CPUINFO_INT_REGISTER + MIPS3_FPR20: mips->cpr[1][20] = info->i; break; |
| 437 | | case CPUINFO_INT_REGISTER + MIPS3_FPR21: mips->cpr[1][21] = info->i; break; |
| 438 | | case CPUINFO_INT_REGISTER + MIPS3_FPR22: mips->cpr[1][22] = info->i; break; |
| 439 | | case CPUINFO_INT_REGISTER + MIPS3_FPR23: mips->cpr[1][23] = info->i; break; |
| 440 | | case CPUINFO_INT_REGISTER + MIPS3_FPR24: mips->cpr[1][24] = info->i; break; |
| 441 | | case CPUINFO_INT_REGISTER + MIPS3_FPR25: mips->cpr[1][25] = info->i; break; |
| 442 | | case CPUINFO_INT_REGISTER + MIPS3_FPR26: mips->cpr[1][26] = info->i; break; |
| 443 | | case CPUINFO_INT_REGISTER + MIPS3_FPR27: mips->cpr[1][27] = info->i; break; |
| 444 | | case CPUINFO_INT_REGISTER + MIPS3_FPR28: mips->cpr[1][28] = info->i; break; |
| 445 | | case CPUINFO_INT_REGISTER + MIPS3_FPR29: mips->cpr[1][29] = info->i; break; |
| 446 | | case CPUINFO_INT_REGISTER + MIPS3_FPR30: mips->cpr[1][30] = info->i; break; |
| 447 | | case CPUINFO_INT_REGISTER + MIPS3_FPR31: mips->cpr[1][31] = info->i; break; |
| 448 | | } |
| 449 | | } |
| 450 | | |
| 451 | | |
| 452 | | /*------------------------------------------------- |
| 453 | | mips3com_get_info - get information about |
| 454 | | a MIPS 3 CPU |
| 455 | | -------------------------------------------------*/ |
| 456 | | |
| 457 | | void mips3com_get_info(mips3_state *mips, UINT32 state, cpuinfo *info) |
| 458 | | { |
| 459 | | switch (state) |
| 460 | | { |
| 461 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 462 | | case CPUINFO_INT_CONTEXT_SIZE: /* provided by core */ break; |
| 463 | | case CPUINFO_INT_INPUT_LINES: info->i = 6; break; |
| 464 | | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 465 | | case CPUINFO_INT_ENDIANNESS: info->i = mips->bigendian ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; break; |
| 466 | | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 467 | | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break; |
| 468 | | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 4; break; |
| 469 | | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 4; break; |
| 470 | | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; |
| 471 | | case CPUINFO_INT_MAX_CYCLES: info->i = 40; break; |
| 472 | | |
| 473 | | case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM: info->i = MIPS3_MAX_PADDR_SHIFT;break; |
| 474 | | case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM: info->i = 32; break; |
| 475 | | case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM: info->i = 0; break; |
| 476 | | case CPUINFO_INT_LOGADDR_WIDTH_PROGRAM: info->i = 32; break; |
| 477 | | case CPUINFO_INT_PAGE_SHIFT_PROGRAM: info->i = MIPS3_MIN_PAGE_SHIFT; break; |
| 478 | | |
| 479 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ0: info->i = (mips->cpr[0][COP0_Cause] & 0x400) ? ASSERT_LINE : CLEAR_LINE; break; |
| 480 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ1: info->i = (mips->cpr[0][COP0_Cause] & 0x800) ? ASSERT_LINE : CLEAR_LINE; break; |
| 481 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ2: info->i = (mips->cpr[0][COP0_Cause] & 0x1000) ? ASSERT_LINE : CLEAR_LINE; break; |
| 482 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ3: info->i = (mips->cpr[0][COP0_Cause] & 0x2000) ? ASSERT_LINE : CLEAR_LINE; break; |
| 483 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ4: info->i = (mips->cpr[0][COP0_Cause] & 0x4000) ? ASSERT_LINE : CLEAR_LINE; break; |
| 484 | | case CPUINFO_INT_INPUT_STATE + MIPS3_IRQ5: info->i = (mips->cpr[0][COP0_Cause] & 0x8000) ? ASSERT_LINE : CLEAR_LINE; break; |
| 485 | | |
| 486 | | case CPUINFO_INT_PREVIOUSPC: /* optionally implemented */ break; |
| 487 | | |
| 488 | | case CPUINFO_INT_PC: |
| 489 | | case CPUINFO_INT_REGISTER + MIPS3_PC: info->i = mips->pc; break; |
| 490 | | case CPUINFO_INT_REGISTER + MIPS3_SR: info->i = mips->cpr[0][COP0_Status]; break; |
| 491 | | case CPUINFO_INT_REGISTER + MIPS3_EPC: info->i = mips->cpr[0][COP0_EPC]; break; |
| 492 | | case CPUINFO_INT_REGISTER + MIPS3_CAUSE: info->i = mips->cpr[0][COP0_Cause]; break; |
| 493 | | case CPUINFO_INT_REGISTER + MIPS3_COUNT: info->i = ((mips->device->total_cycles() - mips->count_zero_time) / 2); break; |
| 494 | | case CPUINFO_INT_REGISTER + MIPS3_COMPARE: info->i = mips->cpr[0][COP0_Compare]; break; |
| 495 | | case CPUINFO_INT_REGISTER + MIPS3_INDEX: info->i = mips->cpr[0][COP0_Index]; break; |
| 496 | | case CPUINFO_INT_REGISTER + MIPS3_RANDOM: info->i = mips->cpr[0][COP0_Random]; break; |
| 497 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYHI: info->i = mips->cpr[0][COP0_EntryHi]; break; |
| 498 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYLO0: info->i = mips->cpr[0][COP0_EntryLo0]; break; |
| 499 | | case CPUINFO_INT_REGISTER + MIPS3_ENTRYLO1: info->i = mips->cpr[0][COP0_EntryLo1]; break; |
| 500 | | case CPUINFO_INT_REGISTER + MIPS3_PAGEMASK: info->i = mips->cpr[0][COP0_PageMask]; break; |
| 501 | | case CPUINFO_INT_REGISTER + MIPS3_WIRED: info->i = mips->cpr[0][COP0_Wired]; break; |
| 502 | | case CPUINFO_INT_REGISTER + MIPS3_BADVADDR: info->i = mips->cpr[0][COP0_BadVAddr]; break; |
| 503 | | |
| 504 | | case CPUINFO_INT_REGISTER + MIPS3_R0: info->i = mips->r[0]; break; |
| 505 | | case CPUINFO_INT_REGISTER + MIPS3_R1: info->i = mips->r[1]; break; |
| 506 | | case CPUINFO_INT_REGISTER + MIPS3_R2: info->i = mips->r[2]; break; |
| 507 | | case CPUINFO_INT_REGISTER + MIPS3_R3: info->i = mips->r[3]; break; |
| 508 | | case CPUINFO_INT_REGISTER + MIPS3_R4: info->i = mips->r[4]; break; |
| 509 | | case CPUINFO_INT_REGISTER + MIPS3_R5: info->i = mips->r[5]; break; |
| 510 | | case CPUINFO_INT_REGISTER + MIPS3_R6: info->i = mips->r[6]; break; |
| 511 | | case CPUINFO_INT_REGISTER + MIPS3_R7: info->i = mips->r[7]; break; |
| 512 | | case CPUINFO_INT_REGISTER + MIPS3_R8: info->i = mips->r[8]; break; |
| 513 | | case CPUINFO_INT_REGISTER + MIPS3_R9: info->i = mips->r[9]; break; |
| 514 | | case CPUINFO_INT_REGISTER + MIPS3_R10: info->i = mips->r[10]; break; |
| 515 | | case CPUINFO_INT_REGISTER + MIPS3_R11: info->i = mips->r[11]; break; |
| 516 | | case CPUINFO_INT_REGISTER + MIPS3_R12: info->i = mips->r[12]; break; |
| 517 | | case CPUINFO_INT_REGISTER + MIPS3_R13: info->i = mips->r[13]; break; |
| 518 | | case CPUINFO_INT_REGISTER + MIPS3_R14: info->i = mips->r[14]; break; |
| 519 | | case CPUINFO_INT_REGISTER + MIPS3_R15: info->i = mips->r[15]; break; |
| 520 | | case CPUINFO_INT_REGISTER + MIPS3_R16: info->i = mips->r[16]; break; |
| 521 | | case CPUINFO_INT_REGISTER + MIPS3_R17: info->i = mips->r[17]; break; |
| 522 | | case CPUINFO_INT_REGISTER + MIPS3_R18: info->i = mips->r[18]; break; |
| 523 | | case CPUINFO_INT_REGISTER + MIPS3_R19: info->i = mips->r[19]; break; |
| 524 | | case CPUINFO_INT_REGISTER + MIPS3_R20: info->i = mips->r[20]; break; |
| 525 | | case CPUINFO_INT_REGISTER + MIPS3_R21: info->i = mips->r[21]; break; |
| 526 | | case CPUINFO_INT_REGISTER + MIPS3_R22: info->i = mips->r[22]; break; |
| 527 | | case CPUINFO_INT_REGISTER + MIPS3_R23: info->i = mips->r[23]; break; |
| 528 | | case CPUINFO_INT_REGISTER + MIPS3_R24: info->i = mips->r[24]; break; |
| 529 | | case CPUINFO_INT_REGISTER + MIPS3_R25: info->i = mips->r[25]; break; |
| 530 | | case CPUINFO_INT_REGISTER + MIPS3_R26: info->i = mips->r[26]; break; |
| 531 | | case CPUINFO_INT_REGISTER + MIPS3_R27: info->i = mips->r[27]; break; |
| 532 | | case CPUINFO_INT_REGISTER + MIPS3_R28: info->i = mips->r[28]; break; |
| 533 | | case CPUINFO_INT_REGISTER + MIPS3_R29: info->i = mips->r[29]; break; |
| 534 | | case CPUINFO_INT_REGISTER + MIPS3_R30: info->i = mips->r[30]; break; |
| 535 | | case CPUINFO_INT_SP: |
| 536 | | case CPUINFO_INT_REGISTER + MIPS3_R31: info->i = mips->r[31]; break; |
| 537 | | case CPUINFO_INT_REGISTER + MIPS3_HI: info->i = mips->r[REG_HI]; break; |
| 538 | | case CPUINFO_INT_REGISTER + MIPS3_LO: info->i = mips->r[REG_LO]; break; |
| 539 | | |
| 540 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 541 | | case CPUINFO_FCT_SET_INFO: /* provided by core */ break; |
| 542 | | case CPUINFO_FCT_INIT: /* provided by core */ break; |
| 543 | | case CPUINFO_FCT_RESET: /* provided by core */ break; |
| 544 | | case CPUINFO_FCT_EXIT: /* provided by core */ break; |
| 545 | | case CPUINFO_FCT_EXECUTE: /* provided by core */ break; |
| 546 | | case CPUINFO_FCT_TRANSLATE: /* provided by core */ break; |
| 547 | | case CPUINFO_FCT_DISASSEMBLE: /* provided by core */ break; |
| 548 | | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &mips->icount; break; |
| 549 | | |
| 550 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 551 | | case CPUINFO_STR_NAME: strcpy(info->s, "MIPS III"); break; |
| 552 | | case CPUINFO_STR_FAMILY: strcpy(info->s, "MIPS III"); break; |
| 553 | | case CPUINFO_STR_VERSION: strcpy(info->s, "3.0"); break; |
| 554 | | case CPUINFO_STR_SOURCE_FILE: /* provided by core */ break; |
| 555 | | case CPUINFO_STR_CREDITS: strcpy(info->s, "Copyright Aaron Giles"); break; |
| 556 | | |
| 557 | | case CPUINFO_STR_FLAGS: strcpy(info->s, " "); break; |
| 558 | | |
| 559 | | case CPUINFO_STR_REGISTER + MIPS3_PC: sprintf(info->s, "PC:%08X", mips->pc); break; |
| 560 | | case CPUINFO_STR_REGISTER + MIPS3_SR: sprintf(info->s, "SR:%08X", (UINT32)mips->cpr[0][COP0_Status]); break; |
| 561 | | case CPUINFO_STR_REGISTER + MIPS3_EPC: sprintf(info->s, "EPC:%08X", (UINT32)mips->cpr[0][COP0_EPC]); break; |
| 562 | | case CPUINFO_STR_REGISTER + MIPS3_CAUSE: sprintf(info->s, "Cause:%08X", (UINT32)mips->cpr[0][COP0_Cause]); break; |
| 563 | | case CPUINFO_STR_REGISTER + MIPS3_COUNT: sprintf(info->s, "Count:%08X", (UINT32)((mips->device->total_cycles() - mips->count_zero_time) / 2)); break; |
| 564 | | case CPUINFO_STR_REGISTER + MIPS3_COMPARE: sprintf(info->s, "Compare:%08X", (UINT32)mips->cpr[0][COP0_Compare]); break; |
| 565 | | case CPUINFO_STR_REGISTER + MIPS3_INDEX: sprintf(info->s, "Index:%08X", (UINT32)mips->cpr[0][COP0_Index]); break; |
| 566 | | case CPUINFO_STR_REGISTER + MIPS3_RANDOM: sprintf(info->s, "Random:%08X", (UINT32)mips->cpr[0][COP0_Random]); break; |
| 567 | | case CPUINFO_STR_REGISTER + MIPS3_ENTRYHI: sprintf(info->s, "EntryHi:%08X%08X", (UINT32)(mips->cpr[0][COP0_EntryHi] >> 32), (UINT32)mips->cpr[0][COP0_EntryHi]); break; |
| 568 | | case CPUINFO_STR_REGISTER + MIPS3_ENTRYLO0: sprintf(info->s, "EntryLo0:%08X%08X", (UINT32)(mips->cpr[0][COP0_EntryLo0] >> 32), (UINT32)mips->cpr[0][COP0_EntryLo0]); break; |
| 569 | | case CPUINFO_STR_REGISTER + MIPS3_ENTRYLO1: sprintf(info->s, "EntryLo1:%08X%08X", (UINT32)(mips->cpr[0][COP0_EntryLo1] >> 32), (UINT32)mips->cpr[0][COP0_EntryLo1]); break; |
| 570 | | case CPUINFO_STR_REGISTER + MIPS3_PAGEMASK: sprintf(info->s, "PageMask:%08X%08X", (UINT32)(mips->cpr[0][COP0_PageMask] >> 32), (UINT32)mips->cpr[0][COP0_PageMask]); break; |
| 571 | | case CPUINFO_STR_REGISTER + MIPS3_WIRED: sprintf(info->s, "Wired:%08X", (UINT32)mips->cpr[0][COP0_Wired]); break; |
| 572 | | case CPUINFO_STR_REGISTER + MIPS3_BADVADDR: sprintf(info->s, "BadVAddr:%08X", (UINT32)mips->cpr[0][COP0_BadVAddr]); break; |
| 573 | | |
| 574 | | #if USE_ABI_REG_NAMES |
| 575 | | case CPUINFO_STR_REGISTER + MIPS3_R0: sprintf(info->s, "zero:%08X%08X", (UINT32)(mips->r[0] >> 32), (UINT32)mips->r[0]); break; |
| 576 | | case CPUINFO_STR_REGISTER + MIPS3_R1: sprintf(info->s, "at:%08X%08X", (UINT32)(mips->r[1] >> 32), (UINT32)mips->r[1]); break; |
| 577 | | case CPUINFO_STR_REGISTER + MIPS3_R2: sprintf(info->s, "v0:%08X%08X", (UINT32)(mips->r[2] >> 32), (UINT32)mips->r[2]); break; |
| 578 | | case CPUINFO_STR_REGISTER + MIPS3_R3: sprintf(info->s, "v1:%08X%08X", (UINT32)(mips->r[3] >> 32), (UINT32)mips->r[3]); break; |
| 579 | | case CPUINFO_STR_REGISTER + MIPS3_R4: sprintf(info->s, "a0:%08X%08X", (UINT32)(mips->r[4] >> 32), (UINT32)mips->r[4]); break; |
| 580 | | case CPUINFO_STR_REGISTER + MIPS3_R5: sprintf(info->s, "a1:%08X%08X", (UINT32)(mips->r[5] >> 32), (UINT32)mips->r[5]); break; |
| 581 | | case CPUINFO_STR_REGISTER + MIPS3_R6: sprintf(info->s, "a2:%08X%08X", (UINT32)(mips->r[6] >> 32), (UINT32)mips->r[6]); break; |
| 582 | | case CPUINFO_STR_REGISTER + MIPS3_R7: sprintf(info->s, "a3:%08X%08X", (UINT32)(mips->r[7] >> 32), (UINT32)mips->r[7]); break; |
| 583 | | case CPUINFO_STR_REGISTER + MIPS3_R8: sprintf(info->s, "t0:%08X%08X", (UINT32)(mips->r[8] >> 32), (UINT32)mips->r[8]); break; |
| 584 | | case CPUINFO_STR_REGISTER + MIPS3_R9: sprintf(info->s, "t1:%08X%08X", (UINT32)(mips->r[9] >> 32), (UINT32)mips->r[9]); break; |
| 585 | | case CPUINFO_STR_REGISTER + MIPS3_R10: sprintf(info->s, "t2:%08X%08X", (UINT32)(mips->r[10] >> 32), (UINT32)mips->r[10]); break; |
| 586 | | case CPUINFO_STR_REGISTER + MIPS3_R11: sprintf(info->s, "t3:%08X%08X", (UINT32)(mips->r[11] >> 32), (UINT32)mips->r[11]); break; |
| 587 | | case CPUINFO_STR_REGISTER + MIPS3_R12: sprintf(info->s, "t4:%08X%08X", (UINT32)(mips->r[12] >> 32), (UINT32)mips->r[12]); break; |
| 588 | | case CPUINFO_STR_REGISTER + MIPS3_R13: sprintf(info->s, "t5:%08X%08X", (UINT32)(mips->r[13] >> 32), (UINT32)mips->r[13]); break; |
| 589 | | case CPUINFO_STR_REGISTER + MIPS3_R14: sprintf(info->s, "t6:%08X%08X", (UINT32)(mips->r[14] >> 32), (UINT32)mips->r[14]); break; |
| 590 | | case CPUINFO_STR_REGISTER + MIPS3_R15: sprintf(info->s, "t7:%08X%08X", (UINT32)(mips->r[15] >> 32), (UINT32)mips->r[15]); break; |
| 591 | | case CPUINFO_STR_REGISTER + MIPS3_R16: sprintf(info->s, "s0:%08X%08X", (UINT32)(mips->r[16] >> 32), (UINT32)mips->r[16]); break; |
| 592 | | case CPUINFO_STR_REGISTER + MIPS3_R17: sprintf(info->s, "s1:%08X%08X", (UINT32)(mips->r[17] >> 32), (UINT32)mips->r[17]); break; |
| 593 | | case CPUINFO_STR_REGISTER + MIPS3_R18: sprintf(info->s, "s2:%08X%08X", (UINT32)(mips->r[18] >> 32), (UINT32)mips->r[18]); break; |
| 594 | | case CPUINFO_STR_REGISTER + MIPS3_R19: sprintf(info->s, "s3:%08X%08X", (UINT32)(mips->r[19] >> 32), (UINT32)mips->r[19]); break; |
| 595 | | case CPUINFO_STR_REGISTER + MIPS3_R20: sprintf(info->s, "s4:%08X%08X", (UINT32)(mips->r[20] >> 32), (UINT32)mips->r[20]); break; |
| 596 | | case CPUINFO_STR_REGISTER + MIPS3_R21: sprintf(info->s, "s5:%08X%08X", (UINT32)(mips->r[21] >> 32), (UINT32)mips->r[21]); break; |
| 597 | | case CPUINFO_STR_REGISTER + MIPS3_R22: sprintf(info->s, "s6:%08X%08X", (UINT32)(mips->r[22] >> 32), (UINT32)mips->r[22]); break; |
| 598 | | case CPUINFO_STR_REGISTER + MIPS3_R23: sprintf(info->s, "s7:%08X%08X", (UINT32)(mips->r[23] >> 32), (UINT32)mips->r[23]); break; |
| 599 | | case CPUINFO_STR_REGISTER + MIPS3_R24: sprintf(info->s, "t8:%08X%08X", (UINT32)(mips->r[24] >> 32), (UINT32)mips->r[24]); break; |
| 600 | | case CPUINFO_STR_REGISTER + MIPS3_R25: sprintf(info->s, "t9:%08X%08X", (UINT32)(mips->r[25] >> 32), (UINT32)mips->r[25]); break; |
| 601 | | case CPUINFO_STR_REGISTER + MIPS3_R26: sprintf(info->s, "k0:%08X%08X", (UINT32)(mips->r[26] >> 32), (UINT32)mips->r[26]); break; |
| 602 | | case CPUINFO_STR_REGISTER + MIPS3_R27: sprintf(info->s, "k1:%08X%08X", (UINT32)(mips->r[27] >> 32), (UINT32)mips->r[27]); break; |
| 603 | | case CPUINFO_STR_REGISTER + MIPS3_R28: sprintf(info->s, "gp:%08X%08X", (UINT32)(mips->r[28] >> 32), (UINT32)mips->r[28]); break; |
| 604 | | case CPUINFO_STR_REGISTER + MIPS3_R29: sprintf(info->s, "sp:%08X%08X", (UINT32)(mips->r[29] >> 32), (UINT32)mips->r[29]); break; |
| 605 | | case CPUINFO_STR_REGISTER + MIPS3_R30: sprintf(info->s, "fp:%08X%08X", (UINT32)(mips->r[30] >> 32), (UINT32)mips->r[30]); break; |
| 606 | | case CPUINFO_STR_REGISTER + MIPS3_R31: sprintf(info->s, "ra:%08X%08X", (UINT32)(mips->r[31] >> 32), (UINT32)mips->r[31]); break; |
| 607 | | #else |
| 608 | | case CPUINFO_STR_REGISTER + MIPS3_R0: sprintf(info->s, "R0:%08X%08X", (UINT32)(mips->r[0] >> 32), (UINT32)mips->r[0]); break; |
| 609 | | case CPUINFO_STR_REGISTER + MIPS3_R1: sprintf(info->s, "R1:%08X%08X", (UINT32)(mips->r[1] >> 32), (UINT32)mips->r[1]); break; |
| 610 | | case CPUINFO_STR_REGISTER + MIPS3_R2: sprintf(info->s, "R2:%08X%08X", (UINT32)(mips->r[2] >> 32), (UINT32)mips->r[2]); break; |
| 611 | | case CPUINFO_STR_REGISTER + MIPS3_R3: sprintf(info->s, "R3:%08X%08X", (UINT32)(mips->r[3] >> 32), (UINT32)mips->r[3]); break; |
| 612 | | case CPUINFO_STR_REGISTER + MIPS3_R4: sprintf(info->s, "R4:%08X%08X", (UINT32)(mips->r[4] >> 32), (UINT32)mips->r[4]); break; |
| 613 | | case CPUINFO_STR_REGISTER + MIPS3_R5: sprintf(info->s, "R5:%08X%08X", (UINT32)(mips->r[5] >> 32), (UINT32)mips->r[5]); break; |
| 614 | | case CPUINFO_STR_REGISTER + MIPS3_R6: sprintf(info->s, "R6:%08X%08X", (UINT32)(mips->r[6] >> 32), (UINT32)mips->r[6]); break; |
| 615 | | case CPUINFO_STR_REGISTER + MIPS3_R7: sprintf(info->s, "R7:%08X%08X", (UINT32)(mips->r[7] >> 32), (UINT32)mips->r[7]); break; |
| 616 | | case CPUINFO_STR_REGISTER + MIPS3_R8: sprintf(info->s, "R8:%08X%08X", (UINT32)(mips->r[8] >> 32), (UINT32)mips->r[8]); break; |
| 617 | | case CPUINFO_STR_REGISTER + MIPS3_R9: sprintf(info->s, "R9:%08X%08X", (UINT32)(mips->r[9] >> 32), (UINT32)mips->r[9]); break; |
| 618 | | case CPUINFO_STR_REGISTER + MIPS3_R10: sprintf(info->s, "R10:%08X%08X", (UINT32)(mips->r[10] >> 32), (UINT32)mips->r[10]); break; |
| 619 | | case CPUINFO_STR_REGISTER + MIPS3_R11: sprintf(info->s, "R11:%08X%08X", (UINT32)(mips->r[11] >> 32), (UINT32)mips->r[11]); break; |
| 620 | | case CPUINFO_STR_REGISTER + MIPS3_R12: sprintf(info->s, "R12:%08X%08X", (UINT32)(mips->r[12] >> 32), (UINT32)mips->r[12]); break; |
| 621 | | case CPUINFO_STR_REGISTER + MIPS3_R13: sprintf(info->s, "R13:%08X%08X", (UINT32)(mips->r[13] >> 32), (UINT32)mips->r[13]); break; |
| 622 | | case CPUINFO_STR_REGISTER + MIPS3_R14: sprintf(info->s, "R14:%08X%08X", (UINT32)(mips->r[14] >> 32), (UINT32)mips->r[14]); break; |
| 623 | | case CPUINFO_STR_REGISTER + MIPS3_R15: sprintf(info->s, "R15:%08X%08X", (UINT32)(mips->r[15] >> 32), (UINT32)mips->r[15]); break; |
| 624 | | case CPUINFO_STR_REGISTER + MIPS3_R16: sprintf(info->s, "R16:%08X%08X", (UINT32)(mips->r[16] >> 32), (UINT32)mips->r[16]); break; |
| 625 | | case CPUINFO_STR_REGISTER + MIPS3_R17: sprintf(info->s, "R17:%08X%08X", (UINT32)(mips->r[17] >> 32), (UINT32)mips->r[17]); break; |
| 626 | | case CPUINFO_STR_REGISTER + MIPS3_R18: sprintf(info->s, "R18:%08X%08X", (UINT32)(mips->r[18] >> 32), (UINT32)mips->r[18]); break; |
| 627 | | case CPUINFO_STR_REGISTER + MIPS3_R19: sprintf(info->s, "R19:%08X%08X", (UINT32)(mips->r[19] >> 32), (UINT32)mips->r[19]); break; |
| 628 | | case CPUINFO_STR_REGISTER + MIPS3_R20: sprintf(info->s, "R20:%08X%08X", (UINT32)(mips->r[20] >> 32), (UINT32)mips->r[20]); break; |
| 629 | | case CPUINFO_STR_REGISTER + MIPS3_R21: sprintf(info->s, "R21:%08X%08X", (UINT32)(mips->r[21] >> 32), (UINT32)mips->r[21]); break; |
| 630 | | case CPUINFO_STR_REGISTER + MIPS3_R22: sprintf(info->s, "R22:%08X%08X", (UINT32)(mips->r[22] >> 32), (UINT32)mips->r[22]); break; |
| 631 | | case CPUINFO_STR_REGISTER + MIPS3_R23: sprintf(info->s, "R23:%08X%08X", (UINT32)(mips->r[23] >> 32), (UINT32)mips->r[23]); break; |
| 632 | | case CPUINFO_STR_REGISTER + MIPS3_R24: sprintf(info->s, "R24:%08X%08X", (UINT32)(mips->r[24] >> 32), (UINT32)mips->r[24]); break; |
| 633 | | case CPUINFO_STR_REGISTER + MIPS3_R25: sprintf(info->s, "R25:%08X%08X", (UINT32)(mips->r[25] >> 32), (UINT32)mips->r[25]); break; |
| 634 | | case CPUINFO_STR_REGISTER + MIPS3_R26: sprintf(info->s, "R26:%08X%08X", (UINT32)(mips->r[26] >> 32), (UINT32)mips->r[26]); break; |
| 635 | | case CPUINFO_STR_REGISTER + MIPS3_R27: sprintf(info->s, "R27:%08X%08X", (UINT32)(mips->r[27] >> 32), (UINT32)mips->r[27]); break; |
| 636 | | case CPUINFO_STR_REGISTER + MIPS3_R28: sprintf(info->s, "R28:%08X%08X", (UINT32)(mips->r[28] >> 32), (UINT32)mips->r[28]); break; |
| 637 | | case CPUINFO_STR_REGISTER + MIPS3_R29: sprintf(info->s, "R29:%08X%08X", (UINT32)(mips->r[29] >> 32), (UINT32)mips->r[29]); break; |
| 638 | | case CPUINFO_STR_REGISTER + MIPS3_R30: sprintf(info->s, "R30:%08X%08X", (UINT32)(mips->r[30] >> 32), (UINT32)mips->r[30]); break; |
| 639 | | case CPUINFO_STR_REGISTER + MIPS3_R31: sprintf(info->s, "R31:%08X%08X", (UINT32)(mips->r[31] >> 32), (UINT32)mips->r[31]); break; |
| 640 | | #endif |
| 641 | | case CPUINFO_STR_REGISTER + MIPS3_HI: sprintf(info->s, "HI:%08X%08X", (UINT32)(mips->r[REG_HI] >> 32), (UINT32)mips->r[REG_HI]); break; |
| 642 | | case CPUINFO_STR_REGISTER + MIPS3_LO: sprintf(info->s, "LO:%08X%08X", (UINT32)(mips->r[REG_LO] >> 32), (UINT32)mips->r[REG_LO]); break; |
| 643 | | |
| 644 | | case CPUINFO_STR_REGISTER + MIPS3_CCR1_31: sprintf(info->s, "CCR31:%08X", (UINT32)mips->ccr[1][31]); break; |
| 645 | | |
| 646 | | case CPUINFO_STR_REGISTER + MIPS3_FPR0: sprintf(info->s, "FPR0:%08X%08X", (UINT32)(mips->cpr[1][0] >> 32), (UINT32)mips->cpr[1][0]); break; |
| 647 | | case CPUINFO_STR_REGISTER + MIPS3_FPS0: sprintf(info->s, "FPS0:!%16g", *(float *)&mips->cpr[1][0]); break; |
| 648 | | case CPUINFO_STR_REGISTER + MIPS3_FPD0: sprintf(info->s, "FPD0:!%16g", *(double *)&mips->cpr[1][0]); break; |
| 649 | | case CPUINFO_STR_REGISTER + MIPS3_FPR1: sprintf(info->s, "FPR1:%08X%08X", (UINT32)(mips->cpr[1][1] >> 32), (UINT32)mips->cpr[1][1]); break; |
| 650 | | case CPUINFO_STR_REGISTER + MIPS3_FPS1: sprintf(info->s, "FPS1:!%16g", *(float *)&mips->cpr[1][1]); break; |
| 651 | | case CPUINFO_STR_REGISTER + MIPS3_FPD1: sprintf(info->s, "FPD1:!%16g", *(double *)&mips->cpr[1][1]); break; |
| 652 | | case CPUINFO_STR_REGISTER + MIPS3_FPR2: sprintf(info->s, "FPR2:%08X%08X", (UINT32)(mips->cpr[1][2] >> 32), (UINT32)mips->cpr[1][2]); break; |
| 653 | | case CPUINFO_STR_REGISTER + MIPS3_FPS2: sprintf(info->s, "FPS2:!%16g", *(float *)&mips->cpr[1][2]); break; |
| 654 | | case CPUINFO_STR_REGISTER + MIPS3_FPD2: sprintf(info->s, "FPD2:!%16g", *(double *)&mips->cpr[1][2]); break; |
| 655 | | case CPUINFO_STR_REGISTER + MIPS3_FPR3: sprintf(info->s, "FPR3:%08X%08X", (UINT32)(mips->cpr[1][3] >> 32), (UINT32)mips->cpr[1][3]); break; |
| 656 | | case CPUINFO_STR_REGISTER + MIPS3_FPS3: sprintf(info->s, "FPS3:!%16g", *(float *)&mips->cpr[1][3]); break; |
| 657 | | case CPUINFO_STR_REGISTER + MIPS3_FPD3: sprintf(info->s, "FPD3:!%16g", *(double *)&mips->cpr[1][3]); break; |
| 658 | | case CPUINFO_STR_REGISTER + MIPS3_FPR4: sprintf(info->s, "FPR4:%08X%08X", (UINT32)(mips->cpr[1][4] >> 32), (UINT32)mips->cpr[1][4]); break; |
| 659 | | case CPUINFO_STR_REGISTER + MIPS3_FPS4: sprintf(info->s, "FPS4:!%16g", *(float *)&mips->cpr[1][4]); break; |
| 660 | | case CPUINFO_STR_REGISTER + MIPS3_FPD4: sprintf(info->s, "FPD4:!%16g", *(double *)&mips->cpr[1][4]); break; |
| 661 | | case CPUINFO_STR_REGISTER + MIPS3_FPR5: sprintf(info->s, "FPR5:%08X%08X", (UINT32)(mips->cpr[1][5] >> 32), (UINT32)mips->cpr[1][5]); break; |
| 662 | | case CPUINFO_STR_REGISTER + MIPS3_FPS5: sprintf(info->s, "FPS5:!%16g", *(float *)&mips->cpr[1][5]); break; |
| 663 | | case CPUINFO_STR_REGISTER + MIPS3_FPD5: sprintf(info->s, "FPD5:!%16g", *(double *)&mips->cpr[1][5]); break; |
| 664 | | case CPUINFO_STR_REGISTER + MIPS3_FPR6: sprintf(info->s, "FPR6:%08X%08X", (UINT32)(mips->cpr[1][6] >> 32), (UINT32)mips->cpr[1][6]); break; |
| 665 | | case CPUINFO_STR_REGISTER + MIPS3_FPS6: sprintf(info->s, "FPS6:!%16g", *(float *)&mips->cpr[1][6]); break; |
| 666 | | case CPUINFO_STR_REGISTER + MIPS3_FPD6: sprintf(info->s, "FPD6:!%16g", *(double *)&mips->cpr[1][6]); break; |
| 667 | | case CPUINFO_STR_REGISTER + MIPS3_FPR7: sprintf(info->s, "FPR7:%08X%08X", (UINT32)(mips->cpr[1][7] >> 32), (UINT32)mips->cpr[1][7]); break; |
| 668 | | case CPUINFO_STR_REGISTER + MIPS3_FPS7: sprintf(info->s, "FPS7:!%16g", *(float *)&mips->cpr[1][7]); break; |
| 669 | | case CPUINFO_STR_REGISTER + MIPS3_FPD7: sprintf(info->s, "FPD7:!%16g", *(double *)&mips->cpr[1][7]); break; |
| 670 | | case CPUINFO_STR_REGISTER + MIPS3_FPR8: sprintf(info->s, "FPR8:%08X%08X", (UINT32)(mips->cpr[1][8] >> 32), (UINT32)mips->cpr[1][8]); break; |
| 671 | | case CPUINFO_STR_REGISTER + MIPS3_FPS8: sprintf(info->s, "FPS8:!%16g", *(float *)&mips->cpr[1][8]); break; |
| 672 | | case CPUINFO_STR_REGISTER + MIPS3_FPD8: sprintf(info->s, "FPD8:!%16g", *(double *)&mips->cpr[1][8]); break; |
| 673 | | case CPUINFO_STR_REGISTER + MIPS3_FPR9: sprintf(info->s, "FPR9:%08X%08X", (UINT32)(mips->cpr[1][9] >> 32), (UINT32)mips->cpr[1][9]); break; |
| 674 | | case CPUINFO_STR_REGISTER + MIPS3_FPS9: sprintf(info->s, "FPS9:!%16g", *(float *)&mips->cpr[1][9]); break; |
| 675 | | case CPUINFO_STR_REGISTER + MIPS3_FPD9: sprintf(info->s, "FPD9:!%16g", *(double *)&mips->cpr[1][9]); break; |
| 676 | | case CPUINFO_STR_REGISTER + MIPS3_FPR10: sprintf(info->s, "FPR10:%08X%08X", (UINT32)(mips->cpr[1][10] >> 32), (UINT32)mips->cpr[1][10]); break; |
| 677 | | case CPUINFO_STR_REGISTER + MIPS3_FPS10: sprintf(info->s, "FPS10:!%16g", *(float *)&mips->cpr[1][10]); break; |
| 678 | | case CPUINFO_STR_REGISTER + MIPS3_FPD10: sprintf(info->s, "FPD10:!%16g", *(double *)&mips->cpr[1][10]); break; |
| 679 | | case CPUINFO_STR_REGISTER + MIPS3_FPR11: sprintf(info->s, "FPR11:%08X%08X", (UINT32)(mips->cpr[1][11] >> 32), (UINT32)mips->cpr[1][11]); break; |
| 680 | | case CPUINFO_STR_REGISTER + MIPS3_FPS11: sprintf(info->s, "FPS11:!%16g", *(float *)&mips->cpr[1][11]); break; |
| 681 | | case CPUINFO_STR_REGISTER + MIPS3_FPD11: sprintf(info->s, "FPD11:!%16g", *(double *)&mips->cpr[1][11]); break; |
| 682 | | case CPUINFO_STR_REGISTER + MIPS3_FPR12: sprintf(info->s, "FPR12:%08X%08X", (UINT32)(mips->cpr[1][12] >> 32), (UINT32)mips->cpr[1][12]); break; |
| 683 | | case CPUINFO_STR_REGISTER + MIPS3_FPS12: sprintf(info->s, "FPS12:!%16g", *(float *)&mips->cpr[1][12]); break; |
| 684 | | case CPUINFO_STR_REGISTER + MIPS3_FPD12: sprintf(info->s, "FPD12:!%16g", *(double *)&mips->cpr[1][12]); break; |
| 685 | | case CPUINFO_STR_REGISTER + MIPS3_FPR13: sprintf(info->s, "FPR13:%08X%08X", (UINT32)(mips->cpr[1][13] >> 32), (UINT32)mips->cpr[1][13]); break; |
| 686 | | case CPUINFO_STR_REGISTER + MIPS3_FPS13: sprintf(info->s, "FPS13:!%16g", *(float *)&mips->cpr[1][13]); break; |
| 687 | | case CPUINFO_STR_REGISTER + MIPS3_FPD13: sprintf(info->s, "FPD13:!%16g", *(double *)&mips->cpr[1][13]); break; |
| 688 | | case CPUINFO_STR_REGISTER + MIPS3_FPR14: sprintf(info->s, "FPR14:%08X%08X", (UINT32)(mips->cpr[1][14] >> 32), (UINT32)mips->cpr[1][14]); break; |
| 689 | | case CPUINFO_STR_REGISTER + MIPS3_FPS14: sprintf(info->s, "FPS14:!%16g", *(float *)&mips->cpr[1][14]); break; |
| 690 | | case CPUINFO_STR_REGISTER + MIPS3_FPD14: sprintf(info->s, "FPD14:!%16g", *(double *)&mips->cpr[1][14]); break; |
| 691 | | case CPUINFO_STR_REGISTER + MIPS3_FPR15: sprintf(info->s, "FPR15:%08X%08X", (UINT32)(mips->cpr[1][15] >> 32), (UINT32)mips->cpr[1][15]); break; |
| 692 | | case CPUINFO_STR_REGISTER + MIPS3_FPS15: sprintf(info->s, "FPS15:!%16g", *(float *)&mips->cpr[1][15]); break; |
| 693 | | case CPUINFO_STR_REGISTER + MIPS3_FPD15: sprintf(info->s, "FPD15:!%16g", *(double *)&mips->cpr[1][15]); break; |
| 694 | | case CPUINFO_STR_REGISTER + MIPS3_FPR16: sprintf(info->s, "FPR16:%08X%08X", (UINT32)(mips->cpr[1][16] >> 32), (UINT32)mips->cpr[1][16]); break; |
| 695 | | case CPUINFO_STR_REGISTER + MIPS3_FPS16: sprintf(info->s, "FPS16:!%16g", *(float *)&mips->cpr[1][16]); break; |
| 696 | | case CPUINFO_STR_REGISTER + MIPS3_FPD16: sprintf(info->s, "FPD16:!%16g", *(double *)&mips->cpr[1][16]); break; |
| 697 | | case CPUINFO_STR_REGISTER + MIPS3_FPR17: sprintf(info->s, "FPR17:%08X%08X", (UINT32)(mips->cpr[1][17] >> 32), (UINT32)mips->cpr[1][17]); break; |
| 698 | | case CPUINFO_STR_REGISTER + MIPS3_FPS17: sprintf(info->s, "FPS17:!%16g", *(float *)&mips->cpr[1][17]); break; |
| 699 | | case CPUINFO_STR_REGISTER + MIPS3_FPD17: sprintf(info->s, "FPD17:!%16g", *(double *)&mips->cpr[1][17]); break; |
| 700 | | case CPUINFO_STR_REGISTER + MIPS3_FPR18: sprintf(info->s, "FPR18:%08X%08X", (UINT32)(mips->cpr[1][18] >> 32), (UINT32)mips->cpr[1][18]); break; |
| 701 | | case CPUINFO_STR_REGISTER + MIPS3_FPS18: sprintf(info->s, "FPS18:!%16g", *(float *)&mips->cpr[1][18]); break; |
| 702 | | case CPUINFO_STR_REGISTER + MIPS3_FPD18: sprintf(info->s, "FPD18:!%16g", *(double *)&mips->cpr[1][18]); break; |
| 703 | | case CPUINFO_STR_REGISTER + MIPS3_FPR19: sprintf(info->s, "FPR19:%08X%08X", (UINT32)(mips->cpr[1][19] >> 32), (UINT32)mips->cpr[1][19]); break; |
| 704 | | case CPUINFO_STR_REGISTER + MIPS3_FPS19: sprintf(info->s, "FPS19:!%16g", *(float *)&mips->cpr[1][19]); break; |
| 705 | | case CPUINFO_STR_REGISTER + MIPS3_FPD19: sprintf(info->s, "FPD19:!%16g", *(double *)&mips->cpr[1][19]); break; |
| 706 | | case CPUINFO_STR_REGISTER + MIPS3_FPR20: sprintf(info->s, "FPR20:%08X%08X", (UINT32)(mips->cpr[1][20] >> 32), (UINT32)mips->cpr[1][20]); break; |
| 707 | | case CPUINFO_STR_REGISTER + MIPS3_FPS20: sprintf(info->s, "FPS20:!%16g", *(float *)&mips->cpr[1][20]); break; |
| 708 | | case CPUINFO_STR_REGISTER + MIPS3_FPD20: sprintf(info->s, "FPD20:!%16g", *(double *)&mips->cpr[1][20]); break; |
| 709 | | case CPUINFO_STR_REGISTER + MIPS3_FPR21: sprintf(info->s, "FPR21:%08X%08X", (UINT32)(mips->cpr[1][21] >> 32), (UINT32)mips->cpr[1][21]); break; |
| 710 | | case CPUINFO_STR_REGISTER + MIPS3_FPS21: sprintf(info->s, "FPS21:!%16g", *(float *)&mips->cpr[1][21]); break; |
| 711 | | case CPUINFO_STR_REGISTER + MIPS3_FPD21: sprintf(info->s, "FPD21:!%16g", *(double *)&mips->cpr[1][21]); break; |
| 712 | | case CPUINFO_STR_REGISTER + MIPS3_FPR22: sprintf(info->s, "FPR22:%08X%08X", (UINT32)(mips->cpr[1][22] >> 32), (UINT32)mips->cpr[1][22]); break; |
| 713 | | case CPUINFO_STR_REGISTER + MIPS3_FPS22: sprintf(info->s, "FPS22:!%16g", *(float *)&mips->cpr[1][22]); break; |
| 714 | | case CPUINFO_STR_REGISTER + MIPS3_FPD22: sprintf(info->s, "FPD22:!%16g", *(double *)&mips->cpr[1][22]); break; |
| 715 | | case CPUINFO_STR_REGISTER + MIPS3_FPR23: sprintf(info->s, "FPR23:%08X%08X", (UINT32)(mips->cpr[1][23] >> 32), (UINT32)mips->cpr[1][23]); break; |
| 716 | | case CPUINFO_STR_REGISTER + MIPS3_FPS23: sprintf(info->s, "FPS23:!%16g", *(float *)&mips->cpr[1][23]); break; |
| 717 | | case CPUINFO_STR_REGISTER + MIPS3_FPD23: sprintf(info->s, "FPD23:!%16g", *(double *)&mips->cpr[1][23]); break; |
| 718 | | case CPUINFO_STR_REGISTER + MIPS3_FPR24: sprintf(info->s, "FPR24:%08X%08X", (UINT32)(mips->cpr[1][24] >> 32), (UINT32)mips->cpr[1][24]); break; |
| 719 | | case CPUINFO_STR_REGISTER + MIPS3_FPS24: sprintf(info->s, "FPS24:!%16g", *(float *)&mips->cpr[1][24]); break; |
| 720 | | case CPUINFO_STR_REGISTER + MIPS3_FPD24: sprintf(info->s, "FPD24:!%16g", *(double *)&mips->cpr[1][24]); break; |
| 721 | | case CPUINFO_STR_REGISTER + MIPS3_FPR25: sprintf(info->s, "FPR25:%08X%08X", (UINT32)(mips->cpr[1][25] >> 32), (UINT32)mips->cpr[1][25]); break; |
| 722 | | case CPUINFO_STR_REGISTER + MIPS3_FPS25: sprintf(info->s, "FPS25:!%16g", *(float *)&mips->cpr[1][25]); break; |
| 723 | | case CPUINFO_STR_REGISTER + MIPS3_FPD25: sprintf(info->s, "FPD25:!%16g", *(double *)&mips->cpr[1][25]); break; |
| 724 | | case CPUINFO_STR_REGISTER + MIPS3_FPR26: sprintf(info->s, "FPR26:%08X%08X", (UINT32)(mips->cpr[1][26] >> 32), (UINT32)mips->cpr[1][26]); break; |
| 725 | | case CPUINFO_STR_REGISTER + MIPS3_FPS26: sprintf(info->s, "FPS26:!%16g", *(float *)&mips->cpr[1][26]); break; |
| 726 | | case CPUINFO_STR_REGISTER + MIPS3_FPD26: sprintf(info->s, "FPD26:!%16g", *(double *)&mips->cpr[1][26]); break; |
| 727 | | case CPUINFO_STR_REGISTER + MIPS3_FPR27: sprintf(info->s, "FPR27:%08X%08X", (UINT32)(mips->cpr[1][27] >> 32), (UINT32)mips->cpr[1][27]); break; |
| 728 | | case CPUINFO_STR_REGISTER + MIPS3_FPS27: sprintf(info->s, "FPS27:!%16g", *(float *)&mips->cpr[1][27]); break; |
| 729 | | case CPUINFO_STR_REGISTER + MIPS3_FPD27: sprintf(info->s, "FPD27:!%16g", *(double *)&mips->cpr[1][27]); break; |
| 730 | | case CPUINFO_STR_REGISTER + MIPS3_FPR28: sprintf(info->s, "FPR28:%08X%08X", (UINT32)(mips->cpr[1][28] >> 32), (UINT32)mips->cpr[1][28]); break; |
| 731 | | case CPUINFO_STR_REGISTER + MIPS3_FPS28: sprintf(info->s, "FPS28:!%16g", *(float *)&mips->cpr[1][28]); break; |
| 732 | | case CPUINFO_STR_REGISTER + MIPS3_FPD28: sprintf(info->s, "FPD28:!%16g", *(double *)&mips->cpr[1][28]); break; |
| 733 | | case CPUINFO_STR_REGISTER + MIPS3_FPR29: sprintf(info->s, "FPR29:%08X%08X", (UINT32)(mips->cpr[1][29] >> 32), (UINT32)mips->cpr[1][29]); break; |
| 734 | | case CPUINFO_STR_REGISTER + MIPS3_FPS29: sprintf(info->s, "FPS29:!%16g", *(float *)&mips->cpr[1][29]); break; |
| 735 | | case CPUINFO_STR_REGISTER + MIPS3_FPD29: sprintf(info->s, "FPD29:!%16g", *(double *)&mips->cpr[1][29]); break; |
| 736 | | case CPUINFO_STR_REGISTER + MIPS3_FPR30: sprintf(info->s, "FPR30:%08X%08X", (UINT32)(mips->cpr[1][30] >> 32), (UINT32)mips->cpr[1][30]); break; |
| 737 | | case CPUINFO_STR_REGISTER + MIPS3_FPS30: sprintf(info->s, "FPS30:!%16g", *(float *)&mips->cpr[1][30]); break; |
| 738 | | case CPUINFO_STR_REGISTER + MIPS3_FPD30: sprintf(info->s, "FPD30:!%16g", *(double *)&mips->cpr[1][30]); break; |
| 739 | | case CPUINFO_STR_REGISTER + MIPS3_FPR31: sprintf(info->s, "FPR31:%08X%08X", (UINT32)(mips->cpr[1][31] >> 32), (UINT32)mips->cpr[1][31]); break; |
| 740 | | case CPUINFO_STR_REGISTER + MIPS3_FPS31: sprintf(info->s, "FPS31:!%16g", *(float *)&mips->cpr[1][31]); break; |
| 741 | | case CPUINFO_STR_REGISTER + MIPS3_FPD31: sprintf(info->s, "FPD31:!%16g", *(double *)&mips->cpr[1][31]); break; |
| 742 | | } |
| 743 | | } |
| 744 | | |
| 745 | | |
| 746 | | /*************************************************************************** |
| 747 | 192 | INTERNAL HELPERS |
| 748 | 193 | ***************************************************************************/ |
| 749 | 194 | |
| r30757 | r30758 | |
| 752 | 197 | whenever a compare interrupt is generated |
| 753 | 198 | -------------------------------------------------*/ |
| 754 | 199 | |
| 755 | | static TIMER_CALLBACK( compare_int_callback ) |
| 200 | TIMER_CALLBACK_MEMBER( mips3_device::compare_int_callback ) |
| 756 | 201 | { |
| 757 | | legacy_cpu_device *device = (legacy_cpu_device *)ptr; |
| 758 | | device->set_input_line(MIPS3_IRQ5, ASSERT_LINE); |
| 202 | set_input_line(MIPS3_IRQ5, ASSERT_LINE); |
| 759 | 203 | } |
| 760 | 204 | |
| 761 | 205 | |
| r30757 | r30758 | |
| 764 | 208 | of the config register |
| 765 | 209 | -------------------------------------------------*/ |
| 766 | 210 | |
| 767 | | static UINT32 compute_config_register(const mips3_state *mips) |
| 211 | UINT32 mips3_device::compute_config_register() |
| 768 | 212 | { |
| 769 | 213 | /* set the cache line size to 32 bytes */ |
| 770 | 214 | UINT32 configreg = 0x00026030; |
| 771 | 215 | int divisor; |
| 772 | 216 | |
| 773 | 217 | // NEC VR series does not use a 100% compatible COP0/TLB implementation |
| 774 | | if (mips->flavor == MIPS3_TYPE_VR4300) |
| 218 | if (m_flavor == MIPS3_TYPE_VR4300) |
| 775 | 219 | { |
| 776 | 220 | /* |
| 777 | 221 | For VR43xx, Config is as follows: |
| r30757 | r30758 | |
| 790 | 234 | else |
| 791 | 235 | { |
| 792 | 236 | /* set the data cache size */ |
| 793 | | if (mips->icache_size <= 0x01000) configreg |= 0 << 6; |
| 794 | | else if (mips->icache_size <= 0x02000) configreg |= 1 << 6; |
| 795 | | else if (mips->icache_size <= 0x04000) configreg |= 2 << 6; |
| 796 | | else if (mips->icache_size <= 0x08000) configreg |= 3 << 6; |
| 797 | | else if (mips->icache_size <= 0x10000) configreg |= 4 << 6; |
| 798 | | else if (mips->icache_size <= 0x20000) configreg |= 5 << 6; |
| 799 | | else if (mips->icache_size <= 0x40000) configreg |= 6 << 6; |
| 237 | if (c_icache_size <= 0x01000) configreg |= 0 << 6; |
| 238 | else if (c_icache_size <= 0x02000) configreg |= 1 << 6; |
| 239 | else if (c_icache_size <= 0x04000) configreg |= 2 << 6; |
| 240 | else if (c_icache_size <= 0x08000) configreg |= 3 << 6; |
| 241 | else if (c_icache_size <= 0x10000) configreg |= 4 << 6; |
| 242 | else if (c_icache_size <= 0x20000) configreg |= 5 << 6; |
| 243 | else if (c_icache_size <= 0x40000) configreg |= 6 << 6; |
| 800 | 244 | else configreg |= 7 << 6; |
| 801 | 245 | |
| 802 | 246 | /* set the instruction cache size */ |
| 803 | | if (mips->icache_size <= 0x01000) configreg |= 0 << 9; |
| 804 | | else if (mips->icache_size <= 0x02000) configreg |= 1 << 9; |
| 805 | | else if (mips->icache_size <= 0x04000) configreg |= 2 << 9; |
| 806 | | else if (mips->icache_size <= 0x08000) configreg |= 3 << 9; |
| 807 | | else if (mips->icache_size <= 0x10000) configreg |= 4 << 9; |
| 808 | | else if (mips->icache_size <= 0x20000) configreg |= 5 << 9; |
| 809 | | else if (mips->icache_size <= 0x40000) configreg |= 6 << 9; |
| 247 | if (c_icache_size <= 0x01000) configreg |= 0 << 9; |
| 248 | else if (c_icache_size <= 0x02000) configreg |= 1 << 9; |
| 249 | else if (c_icache_size <= 0x04000) configreg |= 2 << 9; |
| 250 | else if (c_icache_size <= 0x08000) configreg |= 3 << 9; |
| 251 | else if (c_icache_size <= 0x10000) configreg |= 4 << 9; |
| 252 | else if (c_icache_size <= 0x20000) configreg |= 5 << 9; |
| 253 | else if (c_icache_size <= 0x40000) configreg |= 6 << 9; |
| 810 | 254 | else configreg |= 7 << 9; |
| 811 | 255 | |
| 812 | 256 | |
| 813 | 257 | /* set the system clock divider */ |
| 814 | 258 | divisor = 2; |
| 815 | | if (mips->system_clock != 0) |
| 259 | if (c_system_clock != 0) |
| 816 | 260 | { |
| 817 | | divisor = mips->cpu_clock / mips->system_clock; |
| 818 | | if (mips->system_clock * divisor != mips->cpu_clock) |
| 261 | divisor = m_cpu_clock / c_system_clock; |
| 262 | if (c_system_clock * divisor != m_cpu_clock) |
| 819 | 263 | { |
| 820 | 264 | configreg |= 0x80000000; |
| 821 | | divisor = mips->cpu_clock * 2 / mips->system_clock; |
| 265 | divisor = m_cpu_clock * 2 / c_system_clock; |
| 822 | 266 | } |
| 823 | 267 | } |
| 824 | 268 | configreg |= (((divisor < 2) ? 2 : (divisor > 8) ? 8 : divisor) - 2) << 28; |
| 825 | 269 | } |
| 826 | 270 | |
| 827 | 271 | /* set the endianness bit */ |
| 828 | | if (mips->bigendian) |
| 272 | if (m_bigendian) |
| 829 | 273 | configreg |= 0x00008000; |
| 830 | 274 | |
| 831 | 275 | return configreg; |
| r30757 | r30758 | |
| 837 | 281 | of the PRId register |
| 838 | 282 | -------------------------------------------------*/ |
| 839 | 283 | |
| 840 | | static UINT32 compute_prid_register(const mips3_state *mips) |
| 284 | UINT32 mips3_device::compute_prid_register() |
| 841 | 285 | { |
| 842 | | switch (mips->flavor) |
| 286 | switch (m_flavor) |
| 843 | 287 | { |
| 844 | 288 | case MIPS3_TYPE_VR4300: |
| 845 | 289 | return 0x0b00; |
| r30757 | r30758 | |
| 870 | 314 | entry |
| 871 | 315 | -------------------------------------------------*/ |
| 872 | 316 | |
| 873 | | static void tlb_map_entry(mips3_state *mips, int tlbindex) |
| 317 | void mips3_device::tlb_map_entry(int tlbindex) |
| 874 | 318 | { |
| 875 | | int current_asid = mips->cpr[0][COP0_EntryHi] & 0xff; |
| 876 | | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 319 | int current_asid = m_core->cpr[0][COP0_EntryHi] & 0xff; |
| 320 | mips3_tlb_entry *entry = &m_tlb[tlbindex]; |
| 877 | 321 | UINT32 count, vpn; |
| 878 | 322 | int which; |
| 879 | 323 | |
| 880 | 324 | /* the ASID doesn't match the current ASID, and if the page isn't global, unmap it from the TLB */ |
| 881 | 325 | if (!tlb_entry_matches_asid(entry, current_asid) && !tlb_entry_is_global(entry)) |
| 882 | 326 | { |
| 883 | | vtlb_load(mips->vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 884 | | vtlb_load(mips->vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 327 | vtlb_load(m_vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 328 | vtlb_load(m_vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 885 | 329 | return; |
| 886 | 330 | } |
| 887 | 331 | |
| r30757 | r30758 | |
| 889 | 333 | vpn = ((entry->entry_hi >> 13) & 0x07ffffff) << 1; |
| 890 | 334 | if (vpn >= (1 << (MIPS3_MAX_PADDR_SHIFT - MIPS3_MIN_PAGE_SHIFT))) |
| 891 | 335 | { |
| 892 | | vtlb_load(mips->vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 893 | | vtlb_load(mips->vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 336 | vtlb_load(m_vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 337 | vtlb_load(m_vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 894 | 338 | return; |
| 895 | 339 | } |
| 896 | 340 | |
| r30757 | r30758 | |
| 906 | 350 | UINT32 flags = 0; |
| 907 | 351 | |
| 908 | 352 | /* compute physical page index */ |
| 909 | | pfn = (lo >> 6) & mips->pfnmask; |
| 353 | pfn = (lo >> 6) & m_pfnmask; |
| 910 | 354 | |
| 911 | 355 | /* valid? */ |
| 912 | 356 | if ((lo & 2) != 0) |
| r30757 | r30758 | |
| 924 | 368 | |
| 925 | 369 | /* load the virtual TLB with the corresponding entries */ |
| 926 | 370 | if ((effvpn + count) <= (0x80000000 >> MIPS3_MIN_PAGE_SHIFT) || effvpn >= (0xc0000000 >> MIPS3_MIN_PAGE_SHIFT)) |
| 927 | | vtlb_load(mips->vtlb, 2 * tlbindex + which, count, effvpn << MIPS3_MIN_PAGE_SHIFT, (pfn << MIPS3_MIN_PAGE_SHIFT) | flags); |
| 371 | vtlb_load(m_vtlb, 2 * tlbindex + which, count, effvpn << MIPS3_MIN_PAGE_SHIFT, (pfn << MIPS3_MIN_PAGE_SHIFT) | flags); |
| 928 | 372 | else |
| 929 | | vtlb_load(mips->vtlb, 2 * tlbindex + which, 0, 0, 0); |
| 373 | vtlb_load(m_vtlb, 2 * tlbindex + which, 0, 0, 0); |
| 930 | 374 | } |
| 931 | 375 | } |
| 932 | 376 | |
| r30757 | r30758 | |
| 936 | 380 | a TLB entry |
| 937 | 381 | -------------------------------------------------*/ |
| 938 | 382 | |
| 939 | | static void tlb_write_common(mips3_state *mips, int tlbindex) |
| 383 | void mips3_device::tlb_write_common(int tlbindex) |
| 940 | 384 | { |
| 941 | 385 | /* only handle entries within the TLB */ |
| 942 | | if (tlbindex < mips->tlbentries) |
| 386 | if (tlbindex < m_tlbentries) |
| 943 | 387 | { |
| 944 | | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 388 | mips3_tlb_entry *entry = &m_tlb[tlbindex]; |
| 945 | 389 | |
| 946 | 390 | /* fill in the new TLB entry from the COP0 registers */ |
| 947 | | entry->page_mask = mips->cpr[0][COP0_PageMask]; |
| 948 | | entry->entry_hi = mips->cpr[0][COP0_EntryHi] & ~(entry->page_mask & U64(0x0000000001ffe000)); |
| 949 | | entry->entry_lo[0] = mips->cpr[0][COP0_EntryLo0]; |
| 950 | | entry->entry_lo[1] = mips->cpr[0][COP0_EntryLo1]; |
| 391 | entry->page_mask = m_core->cpr[0][COP0_PageMask]; |
| 392 | entry->entry_hi = m_core->cpr[0][COP0_EntryHi] & ~(entry->page_mask & U64(0x0000000001ffe000)); |
| 393 | entry->entry_lo[0] = m_core->cpr[0][COP0_EntryLo0]; |
| 394 | entry->entry_lo[1] = m_core->cpr[0][COP0_EntryLo1]; |
| 951 | 395 | |
| 952 | 396 | /* remap this TLB entry */ |
| 953 | | tlb_map_entry(mips, tlbindex); |
| 397 | tlb_map_entry(tlbindex); |
| 954 | 398 | |
| 955 | 399 | /* log the two halves once they are in */ |
| 956 | 400 | tlb_entry_log_half(entry, tlbindex, 0); |
trunk/src/emu/cpu/mips/mips3.c
| r30757 | r30758 | |
| 23 | 23 | HELPER MACROS |
| 24 | 24 | ***************************************************************************/ |
| 25 | 25 | |
| 26 | | #define RSVAL32 ((UINT32)mips3.core.r[RSREG]) |
| 27 | | #define RTVAL32 ((UINT32)mips3.core.r[RTREG]) |
| 28 | | #define RDVAL32 ((UINT32)mips3.core.r[RDREG]) |
| 26 | #define RSVAL32 ((UINT32)m_core->r[RSREG]) |
| 27 | #define RTVAL32 ((UINT32)m_core->r[RTREG]) |
| 28 | #define RDVAL32 ((UINT32)m_core->r[RDREG]) |
| 29 | 29 | |
| 30 | | #define RSVAL64 (mips3.core.r[RSREG]) |
| 31 | | #define RTVAL64 (mips3.core.r[RTREG]) |
| 32 | | #define RDVAL64 (mips3.core.r[RDREG]) |
| 30 | #define RSVAL64 (m_core->r[RSREG]) |
| 31 | #define RTVAL64 (m_core->r[RTREG]) |
| 32 | #define RDVAL64 (m_core->r[RDREG]) |
| 33 | 33 | |
| 34 | | #define FRVALS_FR0 (((float *)&mips3.core.cpr[1][0])[FRREG]) |
| 35 | | #define FTVALS_FR0 (((float *)&mips3.core.cpr[1][0])[FTREG]) |
| 36 | | #define FSVALS_FR0 (((float *)&mips3.core.cpr[1][0])[FSREG]) |
| 37 | | #define FDVALS_FR0 (((float *)&mips3.core.cpr[1][0])[FDREG]) |
| 38 | | #define FSVALW_FR0 (((UINT32 *)&mips3.core.cpr[1][0])[FSREG]) |
| 39 | | #define FDVALW_FR0 (((UINT32 *)&mips3.core.cpr[1][0])[FDREG]) |
| 34 | #define FRVALS_FR0 (((float *)&m_core->cpr[1][0])[FRREG]) |
| 35 | #define FTVALS_FR0 (((float *)&m_core->cpr[1][0])[FTREG]) |
| 36 | #define FSVALS_FR0 (((float *)&m_core->cpr[1][0])[FSREG]) |
| 37 | #define FDVALS_FR0 (((float *)&m_core->cpr[1][0])[FDREG]) |
| 38 | #define FSVALW_FR0 (((UINT32 *)&m_core->cpr[1][0])[FSREG]) |
| 39 | #define FDVALW_FR0 (((UINT32 *)&m_core->cpr[1][0])[FDREG]) |
| 40 | 40 | |
| 41 | | #define FRVALD_FR0 (*(double *)&mips3.core.cpr[1][FRREG/2]) |
| 42 | | #define FTVALD_FR0 (*(double *)&mips3.core.cpr[1][FTREG/2]) |
| 43 | | #define FSVALD_FR0 (*(double *)&mips3.core.cpr[1][FSREG/2]) |
| 44 | | #define FDVALD_FR0 (*(double *)&mips3.core.cpr[1][FDREG/2]) |
| 45 | | #define FSVALL_FR0 (((UINT64 *)&mips3.core.cpr[1][0])[FSREG/2]) |
| 46 | | #define FDVALL_FR0 (((UINT64 *)&mips3.core.cpr[1][0])[FDREG/2]) |
| 41 | #define FRVALD_FR0 (*(double *)&m_core->cpr[1][FRREG/2]) |
| 42 | #define FTVALD_FR0 (*(double *)&m_core->cpr[1][FTREG/2]) |
| 43 | #define FSVALD_FR0 (*(double *)&m_core->cpr[1][FSREG/2]) |
| 44 | #define FDVALD_FR0 (*(double *)&m_core->cpr[1][FDREG/2]) |
| 45 | #define FSVALL_FR0 (((UINT64 *)&m_core->cpr[1][0])[FSREG/2]) |
| 46 | #define FDVALL_FR0 (((UINT64 *)&m_core->cpr[1][0])[FDREG/2]) |
| 47 | 47 | |
| 48 | | #define FRVALS_FR1 (((float *)&mips3.core.cpr[1][FRREG])[BYTE_XOR_LE(0)]) |
| 49 | | #define FTVALS_FR1 (((float *)&mips3.core.cpr[1][FTREG])[BYTE_XOR_LE(0)]) |
| 50 | | #define FSVALS_FR1 (((float *)&mips3.core.cpr[1][FSREG])[BYTE_XOR_LE(0)]) |
| 51 | | #define FDVALS_FR1 (((float *)&mips3.core.cpr[1][FDREG])[BYTE_XOR_LE(0)]) |
| 52 | | #define FSVALW_FR1 (((UINT32 *)&mips3.core.cpr[1][FSREG])[BYTE_XOR_LE(0)]) |
| 53 | | #define FDVALW_FR1 (((UINT32 *)&mips3.core.cpr[1][FDREG])[BYTE_XOR_LE(0)]) |
| 48 | #define FRVALS_FR1 (((float *)&m_core->cpr[1][FRREG])[BYTE_XOR_LE(0)]) |
| 49 | #define FTVALS_FR1 (((float *)&m_core->cpr[1][FTREG])[BYTE_XOR_LE(0)]) |
| 50 | #define FSVALS_FR1 (((float *)&m_core->cpr[1][FSREG])[BYTE_XOR_LE(0)]) |
| 51 | #define FDVALS_FR1 (((float *)&m_core->cpr[1][FDREG])[BYTE_XOR_LE(0)]) |
| 52 | #define FSVALW_FR1 (((UINT32 *)&m_core->cpr[1][FSREG])[BYTE_XOR_LE(0)]) |
| 53 | #define FDVALW_FR1 (((UINT32 *)&m_core->cpr[1][FDREG])[BYTE_XOR_LE(0)]) |
| 54 | 54 | |
| 55 | | #define FRVALD_FR1 (*(double *)&mips3.core.cpr[1][FRREG]) |
| 56 | | #define FTVALD_FR1 (*(double *)&mips3.core.cpr[1][FTREG]) |
| 57 | | #define FSVALD_FR1 (*(double *)&mips3.core.cpr[1][FSREG]) |
| 58 | | #define FDVALD_FR1 (*(double *)&mips3.core.cpr[1][FDREG]) |
| 59 | | #define FSVALL_FR1 (*(UINT64 *)&mips3.core.cpr[1][FSREG]) |
| 60 | | #define FDVALL_FR1 (*(UINT64 *)&mips3.core.cpr[1][FDREG]) |
| 55 | #define FRVALD_FR1 (*(double *)&m_core->cpr[1][FRREG]) |
| 56 | #define FTVALD_FR1 (*(double *)&m_core->cpr[1][FTREG]) |
| 57 | #define FSVALD_FR1 (*(double *)&m_core->cpr[1][FSREG]) |
| 58 | #define FDVALD_FR1 (*(double *)&m_core->cpr[1][FDREG]) |
| 59 | #define FSVALL_FR1 (*(UINT64 *)&m_core->cpr[1][FSREG]) |
| 60 | #define FDVALL_FR1 (*(UINT64 *)&m_core->cpr[1][FDREG]) |
| 61 | 61 | |
| 62 | | #define ADDPC(x) mips3.nextpc = mips3.core.pc + ((x) << 2) |
| 63 | | #define ADDPCL(x,l) { mips3.nextpc = mips3.core.pc + ((x) << 2); mips3.core.r[l] = (INT32)(mips3.core.pc + 4); } |
| 64 | | #define ABSPC(x) mips3.nextpc = (mips3.core.pc & 0xf0000000) | ((x) << 2) |
| 65 | | #define ABSPCL(x,l) { mips3.nextpc = (mips3.core.pc & 0xf0000000) | ((x) << 2); mips3.core.r[l] = (INT32)(mips3.core.pc + 4); } |
| 66 | | #define SETPC(x) mips3.nextpc = (x) |
| 67 | | #define SETPCL(x,l) { mips3.nextpc = (x); mips3.core.r[l] = (INT32)(mips3.core.pc + 4); } |
| 62 | #define ADDPC(x) m_nextpc = m_core->pc + ((x) << 2) |
| 63 | #define ADDPCL(x,l) { m_nextpc = m_core->pc + ((x) << 2); m_core->r[l] = (INT32)(m_core->pc + 4); } |
| 64 | #define ABSPC(x) m_nextpc = (m_core->pc & 0xf0000000) | ((x) << 2) |
| 65 | #define ABSPCL(x,l) { m_nextpc = (m_core->pc & 0xf0000000) | ((x) << 2); m_core->r[l] = (INT32)(m_core->pc + 4); } |
| 66 | #define SETPC(x) m_nextpc = (x) |
| 67 | #define SETPCL(x,l) { m_nextpc = (x); m_core->r[l] = (INT32)(m_core->pc + 4); } |
| 68 | 68 | |
| 69 | | #define HIVAL (UINT32)mips3.core.r[REG_HI] |
| 70 | | #define LOVAL (UINT32)mips3.core.r[REG_LO] |
| 71 | | #define HIVAL64 mips3.core.r[REG_HI] |
| 72 | | #define LOVAL64 mips3.core.r[REG_LO] |
| 73 | | #define SR mips3.core.cpr[0][COP0_Status] |
| 74 | | #define CAUSE mips3.core.cpr[0][COP0_Cause] |
| 69 | #define HIVAL (UINT32)m_core->r[REG_HI] |
| 70 | #define LOVAL (UINT32)m_core->r[REG_LO] |
| 71 | #define HIVAL64 m_core->r[REG_HI] |
| 72 | #define LOVAL64 m_core->r[REG_LO] |
| 73 | #define SR m_core->cpr[0][COP0_Status] |
| 74 | #define CAUSE m_core->cpr[0][COP0_Cause] |
| 75 | 75 | |
| 76 | | #define GET_FCC(n) (mips3.cf[1][n]) |
| 77 | | #define SET_FCC(n,v) (mips3.cf[1][n] = (v)) |
| 76 | #define GET_FCC(n) (m_cf[1][n]) |
| 77 | #define SET_FCC(n,v) (m_cf[1][n] = (v)) |
| 78 | 78 | |
| 79 | 79 | #define IS_FR0 (!(SR & SR_FR)) |
| 80 | 80 | #define IS_FR1 (SR & SR_FR) |
| 81 | 81 | |
| 82 | /* size of the execution code cache */ |
| 83 | #define CACHE_SIZE (32 * 1024 * 1024) |
| 82 | 84 | |
| 83 | 85 | |
| 84 | | /*************************************************************************** |
| 85 | | STRUCTURES & TYPEDEFS |
| 86 | | ***************************************************************************/ |
| 87 | 86 | |
| 88 | | /* MIPS3 Registers */ |
| 89 | | struct mips3_regs |
| 87 | static const UINT8 fcc_shift[8] = { 23, 25, 26, 27, 28, 29, 30, 31 }; |
| 88 | |
| 89 | /* lookup table for FP modes */ |
| 90 | static const UINT8 fpmode_source[4] = |
| 90 | 91 | { |
| 91 | | /* core state */ |
| 92 | | mips3_state core; |
| 93 | | |
| 94 | | /* internal stuff */ |
| 95 | | UINT32 ppc; |
| 96 | | UINT32 nextpc; |
| 97 | | UINT32 pcbase; |
| 98 | | UINT8 cf[4][8]; |
| 99 | | int op; |
| 100 | | int interrupt_cycles; |
| 101 | | UINT32 ll_value; |
| 102 | | UINT64 lld_value; |
| 103 | | UINT32 badcop_value; |
| 104 | | const vtlb_entry *tlb_table; |
| 105 | | |
| 106 | | /* endian-dependent load/store */ |
| 107 | | void (*lwl)(UINT32 op); |
| 108 | | void (*lwr)(UINT32 op); |
| 109 | | void (*swl)(UINT32 op); |
| 110 | | void (*swr)(UINT32 op); |
| 111 | | void (*ldl)(UINT32 op); |
| 112 | | void (*ldr)(UINT32 op); |
| 113 | | void (*sdl)(UINT32 op); |
| 114 | | void (*sdr)(UINT32 op); |
| 92 | uml::ROUND_ROUND, |
| 93 | uml::ROUND_TRUNC, |
| 94 | uml::ROUND_CEIL, |
| 95 | uml::ROUND_FLOOR |
| 115 | 96 | }; |
| 116 | 97 | |
| 117 | 98 | |
| 118 | 99 | |
| 119 | 100 | /*************************************************************************** |
| 120 | | FUNCTION PROTOTYPES |
| 101 | MEMORY ACCESSORS |
| 121 | 102 | ***************************************************************************/ |
| 122 | 103 | |
| 123 | | static void lwl_be(UINT32 op); |
| 124 | | static void lwr_be(UINT32 op); |
| 125 | | static void swl_be(UINT32 op); |
| 126 | | static void swr_be(UINT32 op); |
| 104 | #define ROPCODE(pc) direct->read_decrypted_dword(pc) |
| 127 | 105 | |
| 128 | | static void lwl_le(UINT32 op); |
| 129 | | static void lwr_le(UINT32 op); |
| 130 | | static void swl_le(UINT32 op); |
| 131 | | static void swr_le(UINT32 op); |
| 132 | 106 | |
| 133 | | static void ldl_be(UINT32 op); |
| 134 | | static void ldr_be(UINT32 op); |
| 135 | | static void sdl_be(UINT32 op); |
| 136 | | static void sdr_be(UINT32 op); |
| 107 | const device_type VR4300BE = &device_creator<vr4300be_device>; |
| 108 | const device_type VR4300LE = &device_creator<vr4300le_device>; |
| 109 | const device_type VR4310BE = &device_creator<vr4310be_device>; |
| 110 | const device_type VR4310LE = &device_creator<vr4310le_device>; |
| 111 | const device_type R4600BE = &device_creator<r4600be_device>; |
| 112 | const device_type R4600LE = &device_creator<r4600le_device>; |
| 113 | const device_type R4650BE = &device_creator<r4650be_device>; |
| 114 | const device_type R4650LE = &device_creator<r4650le_device>; |
| 115 | const device_type R4700BE = &device_creator<r4700be_device>; |
| 116 | const device_type R4700LE = &device_creator<r4700le_device>; |
| 117 | const device_type R5000BE = &device_creator<r5000be_device>; |
| 118 | const device_type R5000LE = &device_creator<r5000le_device>; |
| 119 | const device_type QED5271BE = &device_creator<qed5271be_device>; |
| 120 | const device_type QED5271LE = &device_creator<qed5271le_device>; |
| 121 | const device_type RM7000BE = &device_creator<rm7000be_device>; |
| 122 | const device_type RM7000LE = &device_creator<rm7000le_device>; |
| 137 | 123 | |
| 138 | | static void ldl_le(UINT32 op); |
| 139 | | static void ldr_le(UINT32 op); |
| 140 | | static void sdl_le(UINT32 op); |
| 141 | | static void sdr_le(UINT32 op); |
| 142 | 124 | |
| 143 | | static const UINT8 fcc_shift[8] = { 23, 25, 26, 27, 28, 29, 30, 31 }; |
| 125 | mips3_device::mips3_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, mips3_flavor flavor, endianness_t endianness) |
| 126 | : cpu_device(mconfig, type, name, tag, owner, clock, shortname, __FILE__) |
| 127 | , m_program_config("program", endianness, 32, 32, 0, 32, MIPS3_MIN_PAGE_SHIFT) |
| 128 | , m_flavor(flavor) |
| 129 | , m_core(NULL) |
| 130 | , m_ppc(0) |
| 131 | , m_nextpc(0) |
| 132 | , m_pcbase(0) |
| 133 | , m_op(0) |
| 134 | , m_interrupt_cycles(0) |
| 135 | , m_ll_value(0) |
| 136 | , m_lld_value(0) |
| 137 | , m_badcop_value(0) |
| 138 | , m_tlb_table(NULL) |
| 139 | , m_lwl(endianness == ENDIANNESS_BIG ? &mips3_device::lwl_be : &mips3_device::lwl_le) |
| 140 | , m_lwr(endianness == ENDIANNESS_BIG ? &mips3_device::lwr_be : &mips3_device::lwr_le) |
| 141 | , m_swl(endianness == ENDIANNESS_BIG ? &mips3_device::swl_be : &mips3_device::swl_le) |
| 142 | , m_swr(endianness == ENDIANNESS_BIG ? &mips3_device::swr_be : &mips3_device::swr_le) |
| 143 | , m_ldl(endianness == ENDIANNESS_BIG ? &mips3_device::ldl_be : &mips3_device::ldl_le) |
| 144 | , m_ldr(endianness == ENDIANNESS_BIG ? &mips3_device::ldr_be : &mips3_device::ldr_le) |
| 145 | , m_sdl(endianness == ENDIANNESS_BIG ? &mips3_device::sdl_be : &mips3_device::sdl_le) |
| 146 | , m_sdr(endianness == ENDIANNESS_BIG ? &mips3_device::sdr_be : &mips3_device::sdr_le) |
| 147 | , c_system_clock(0) |
| 148 | , m_pfnmask(0) |
| 149 | , m_tlbentries(0) |
| 150 | , m_bigendian(endianness == ENDIANNESS_BIG) |
| 151 | , c_icache_size(0) |
| 152 | , c_dcache_size(0) |
| 153 | , m_vtlb(NULL) |
| 154 | , m_debugger_temp(0) |
| 155 | , m_cache(CACHE_SIZE + sizeof(internal_mips3_state)) |
| 156 | , m_drcuml(NULL) |
| 157 | , m_drcfe(NULL) |
| 158 | , m_drcoptions(0) |
| 159 | , m_cache_dirty(0) |
| 160 | , m_entry(NULL) |
| 161 | , m_nocode(NULL) |
| 162 | , m_out_of_cycles(NULL) |
| 163 | , m_tlb_mismatch(NULL) |
| 164 | , m_fastram_select(0) |
| 165 | , m_hotspot_select(0) |
| 166 | { |
| 167 | memset(m_fpmode, 0, sizeof(m_fpmode)); |
| 144 | 168 | |
| 169 | for (int i = 0; i < 3; i++) |
| 170 | { |
| 171 | m_read8[i] = NULL; |
| 172 | m_write8[i] = NULL; |
| 173 | m_read16[i] = NULL; |
| 174 | m_write16[i] = NULL; |
| 175 | m_read32[i] = NULL; |
| 176 | m_read32mask[i] = NULL; |
| 177 | m_write32[i] = NULL; |
| 178 | m_write32mask[i] = NULL; |
| 179 | m_read64[i] = NULL; |
| 180 | m_read64mask[i] = NULL; |
| 181 | m_write64[i] = NULL; |
| 182 | m_write64mask[i] = NULL; |
| 183 | } |
| 145 | 184 | |
| 185 | for (int i = 0; i < 18; i++) |
| 186 | { |
| 187 | m_exception[i] = NULL; |
| 188 | m_exception_norecover[i] = NULL; |
| 189 | } |
| 190 | memset(m_fastram, 0, sizeof(m_fastram)); |
| 191 | memset(m_hotspot, 0, sizeof(m_hotspot)); |
| 146 | 192 | |
| 147 | | /*************************************************************************** |
| 148 | | PRIVATE GLOBAL VARIABLES |
| 149 | | ***************************************************************************/ |
| 193 | m_isdrc = mconfig.options().drc() ? true : false; |
| 194 | } |
| 150 | 195 | |
| 151 | | static mips3_regs mips3; |
| 152 | 196 | |
| 197 | void mips3_device::device_stop() |
| 198 | { |
| 199 | if (m_vtlb != NULL) |
| 200 | { |
| 201 | vtlb_free(m_vtlb); |
| 202 | m_vtlb = NULL; |
| 203 | } |
| 153 | 204 | |
| 205 | if (m_drcfe != NULL) |
| 206 | { |
| 207 | auto_free(machine(), m_drcfe); |
| 208 | m_drcfe = NULL; |
| 209 | } |
| 210 | if (m_drcuml != NULL) |
| 211 | { |
| 212 | auto_free(machine(), m_drcuml); |
| 213 | m_drcuml = NULL; |
| 214 | } |
| 215 | } |
| 154 | 216 | |
| 155 | 217 | /*************************************************************************** |
| 156 | | MEMORY ACCESSORS |
| 157 | | ***************************************************************************/ |
| 158 | | |
| 159 | | #define ROPCODE(pc) mips3.core.direct->read_decrypted_dword(pc) |
| 160 | | |
| 161 | | |
| 162 | | /*************************************************************************** |
| 163 | 218 | EXECEPTION HANDLING |
| 164 | 219 | ***************************************************************************/ |
| 165 | 220 | |
| 166 | | INLINE void generate_exception(int exception, int backup) |
| 221 | void mips3_device::generate_exception(int exception, int backup) |
| 167 | 222 | { |
| 168 | 223 | UINT32 offset = 0x180; |
| 169 | 224 | /* |
| r30757 | r30758 | |
| 171 | 226 | |
| 172 | 227 | if (exception != 0) |
| 173 | 228 | { |
| 174 | | fprintf(stderr, "Exception: PC=%08X, PPC=%08X\n", mips3.core.pc, mips3.ppc); |
| 175 | | debugger_break(Machine); |
| 229 | fprintf(stderr, "Exception: PC=%08X, PPC=%08X\n", m_core->pc, m_ppc); |
| 230 | debugger_break(machine()); |
| 176 | 231 | } |
| 177 | 232 | */ |
| 178 | 233 | |
| 179 | 234 | /* back up if necessary */ |
| 180 | 235 | if (backup) |
| 181 | | mips3.core.pc = mips3.ppc; |
| 236 | m_core->pc = m_ppc; |
| 182 | 237 | |
| 183 | 238 | /* translate our fake fill exceptions into real exceptions */ |
| 184 | 239 | if (exception == EXCEPTION_TLBLOAD_FILL || exception == EXCEPTION_TLBSTORE_FILL) |
| r30757 | r30758 | |
| 188 | 243 | } |
| 189 | 244 | |
| 190 | 245 | /* set the exception PC */ |
| 191 | | mips3.core.cpr[0][COP0_EPC] = mips3.core.pc; |
| 246 | m_core->cpr[0][COP0_EPC] = m_core->pc; |
| 192 | 247 | |
| 193 | 248 | /* put the cause in the low 8 bits and clear the branch delay flag */ |
| 194 | 249 | CAUSE = (CAUSE & ~0x800000ff) | (exception << 2); |
| r30757 | r30758 | |
| 196 | 251 | /* set the appropriate bits for coprocessor exceptions */ |
| 197 | 252 | if(exception == EXCEPTION_BADCOP) |
| 198 | 253 | { |
| 199 | | CAUSE |= mips3.badcop_value << 28; |
| 254 | CAUSE |= m_badcop_value << 28; |
| 200 | 255 | } |
| 201 | 256 | |
| 202 | 257 | /* if we were in a branch delay slot, adjust */ |
| 203 | | if (mips3.nextpc != ~0) |
| 258 | if (m_nextpc != ~0) |
| 204 | 259 | { |
| 205 | | mips3.nextpc = ~0; |
| 206 | | mips3.core.cpr[0][COP0_EPC] -= 4; |
| 260 | m_nextpc = ~0; |
| 261 | m_core->cpr[0][COP0_EPC] -= 4; |
| 207 | 262 | CAUSE |= 0x80000000; |
| 208 | 263 | } |
| 209 | 264 | |
| r30757 | r30758 | |
| 211 | 266 | SR |= SR_EXL; |
| 212 | 267 | |
| 213 | 268 | /* based on the BEV bit, we either go to ROM or RAM */ |
| 214 | | mips3.core.pc = (SR & SR_BEV) ? 0xbfc00200 : 0x80000000; |
| 269 | m_core->pc = (SR & SR_BEV) ? 0xbfc00200 : 0x80000000; |
| 215 | 270 | |
| 216 | 271 | /* most exceptions go to offset 0x180, except for TLB stuff */ |
| 217 | 272 | if (exception >= EXCEPTION_TLBMOD && exception <= EXCEPTION_TLBSTORE) |
| 218 | 273 | { |
| 219 | | osd_printf_debug("TLB miss @ %08X\n", (UINT32)mips3.core.cpr[0][COP0_BadVAddr]); |
| 274 | osd_printf_debug("TLB miss @ %08X\n", (UINT32)m_core->cpr[0][COP0_BadVAddr]); |
| 220 | 275 | } |
| 221 | | mips3.core.pc += offset; |
| 276 | m_core->pc += offset; |
| 222 | 277 | |
| 223 | 278 | /* |
| 224 | 279 | useful for tracking interrupts |
| 225 | 280 | |
| 226 | 281 | if ((CAUSE & 0x7f) == 0) |
| 227 | | logerror("Took interrupt -- Cause = %08X, PC = %08X\n", (UINT32)CAUSE, mips3.core.pc); |
| 282 | logerror("Took interrupt -- Cause = %08X, PC = %08X\n", (UINT32)CAUSE, m_core->pc); |
| 228 | 283 | */ |
| 229 | 284 | } |
| 230 | 285 | |
| 231 | 286 | |
| 232 | | static void generate_tlb_exception(int exception, offs_t address) |
| 287 | void mips3_device::generate_tlb_exception(int exception, offs_t address) |
| 233 | 288 | { |
| 234 | | mips3.core.cpr[0][COP0_BadVAddr] = address; |
| 289 | m_core->cpr[0][COP0_BadVAddr] = address; |
| 235 | 290 | if(exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE || exception == EXCEPTION_TLBLOAD_FILL || exception == EXCEPTION_TLBSTORE_FILL) |
| 236 | 291 | { |
| 237 | | mips3.core.cpr[0][COP0_Context] = (mips3.core.cpr[0][COP0_Context] & 0xff800000) | ((address >> 9) & 0x007ffff0); |
| 238 | | mips3.core.cpr[0][COP0_EntryHi] = (address & 0xffffe000) | (mips3.core.cpr[0][COP0_EntryHi] & 0xff); |
| 292 | m_core->cpr[0][COP0_Context] = (m_core->cpr[0][COP0_Context] & 0xff800000) | ((address >> 9) & 0x007ffff0); |
| 293 | m_core->cpr[0][COP0_EntryHi] = (address & 0xffffe000) | (m_core->cpr[0][COP0_EntryHi] & 0xff); |
| 239 | 294 | } |
| 240 | 295 | generate_exception(exception, 1); |
| 241 | 296 | } |
| 242 | 297 | |
| 243 | 298 | |
| 244 | | INLINE void invalid_instruction(UINT32 op) |
| 299 | void mips3_device::invalid_instruction(UINT32 op) |
| 245 | 300 | { |
| 246 | 301 | generate_exception(EXCEPTION_INVALIDOP, 1); |
| 247 | 302 | } |
| r30757 | r30758 | |
| 252 | 307 | IRQ HANDLING |
| 253 | 308 | ***************************************************************************/ |
| 254 | 309 | |
| 255 | | static void check_irqs(void) |
| 310 | void mips3_device::check_irqs() |
| 256 | 311 | { |
| 257 | 312 | if ((CAUSE & SR & 0xfc00) && (SR & SR_IE) && !(SR & SR_EXL) && !(SR & SR_ERL)) |
| 258 | 313 | generate_exception(EXCEPTION_INTERRUPT, 0); |
| r30757 | r30758 | |
| 264 | 319 | CORE CALLBACKS |
| 265 | 320 | ***************************************************************************/ |
| 266 | 321 | |
| 267 | | static CPU_RESET( mips3 ) |
| 322 | void mips3_device::device_start() |
| 268 | 323 | { |
| 269 | | /* common reset */ |
| 270 | | mips3com_reset(&mips3.core); |
| 271 | | mips3.nextpc = ~0; |
| 272 | | memset(mips3.cf, 0, sizeof(mips3.cf)); |
| 324 | /* allocate the implementation-specific state from the full cache */ |
| 325 | m_core = (internal_mips3_state *)m_cache.alloc_near(sizeof(internal_mips3_state)); |
| 273 | 326 | |
| 327 | /* initialize based on the config */ |
| 328 | memset(m_core, 0, sizeof(internal_mips3_state)); |
| 329 | |
| 330 | m_cpu_clock = clock(); |
| 331 | m_program = &space(AS_PROGRAM); |
| 332 | m_direct = &m_program->direct(); |
| 333 | |
| 334 | /* configure flavor-specific parameters */ |
| 335 | m_pfnmask = 0x00ffffff; |
| 336 | m_tlbentries = MIPS3_MAX_TLB_ENTRIES; |
| 337 | |
| 338 | /* VR4300 and VR5432 have 4 fewer PFN bits, and only 32 TLB entries */ |
| 339 | if (m_flavor == MIPS3_TYPE_VR4300) |
| 340 | { |
| 341 | m_pfnmask = 0x000fffff; |
| 342 | m_tlbentries = 32; |
| 343 | } |
| 344 | |
| 274 | 345 | /* set up the endianness */ |
| 275 | | if (mips3.core.bigendian) |
| 346 | m_program->accessors(m_memory); |
| 347 | |
| 348 | /* allocate the virtual TLB */ |
| 349 | m_vtlb = vtlb_alloc(this, AS_PROGRAM, 2 * m_tlbentries + 2, 0); |
| 350 | |
| 351 | /* allocate a timer for the compare interrupt */ |
| 352 | m_compare_int_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mips3_device::compare_int_callback), this)); |
| 353 | |
| 354 | m_tlb_table = vtlb_table(m_vtlb); |
| 355 | |
| 356 | UINT32 flags = 0; |
| 357 | /* initialize the UML generator */ |
| 358 | if (LOG_UML) |
| 359 | flags |= DRCUML_OPTION_LOG_UML; |
| 360 | if (LOG_NATIVE) |
| 361 | flags |= DRCUML_OPTION_LOG_NATIVE; |
| 362 | m_drcuml = auto_alloc(machine(), drcuml_state(*this, m_cache, flags, 8, 32, 2)); |
| 363 | |
| 364 | /* add symbols for our stuff */ |
| 365 | m_drcuml->symbol_add(&m_core->pc, sizeof(m_core->pc), "pc"); |
| 366 | m_drcuml->symbol_add(&m_core->icount, sizeof(m_core->icount), "icount"); |
| 367 | for (int regnum = 0; regnum < 32; regnum++) |
| 276 | 368 | { |
| 277 | | mips3.lwl = lwl_be; |
| 278 | | mips3.lwr = lwr_be; |
| 279 | | mips3.swl = swl_be; |
| 280 | | mips3.swr = swr_be; |
| 281 | | mips3.ldl = ldl_be; |
| 282 | | mips3.ldr = ldr_be; |
| 283 | | mips3.sdl = sdl_be; |
| 284 | | mips3.sdr = sdr_be; |
| 369 | char buf[10]; |
| 370 | sprintf(buf, "r%d", regnum); |
| 371 | m_drcuml->symbol_add(&m_core->r[regnum], sizeof(m_core->r[regnum]), buf); |
| 372 | sprintf(buf, "f%d", regnum); |
| 373 | m_drcuml->symbol_add(&m_core->cpr[1][regnum], sizeof(m_core->cpr[1][regnum]), buf); |
| 285 | 374 | } |
| 286 | | else |
| 375 | m_drcuml->symbol_add(&m_core->r[REG_LO], sizeof(m_core->r[REG_LO]), "lo"); |
| 376 | m_drcuml->symbol_add(&m_core->r[REG_HI], sizeof(m_core->r[REG_LO]), "hi"); |
| 377 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Index], sizeof(m_core->cpr[0][COP0_Index]), "Index"); |
| 378 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Random], sizeof(m_core->cpr[0][COP0_Random]), "Random"); |
| 379 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_EntryLo0], sizeof(m_core->cpr[0][COP0_EntryLo0]), "EntryLo0"); |
| 380 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_EntryLo1], sizeof(m_core->cpr[0][COP0_EntryLo1]), "EntryLo1"); |
| 381 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Context], sizeof(m_core->cpr[0][COP0_Context]), "Context"); |
| 382 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_PageMask], sizeof(m_core->cpr[0][COP0_PageMask]), "PageMask"); |
| 383 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Wired], sizeof(m_core->cpr[0][COP0_Wired]), "Wired"); |
| 384 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_BadVAddr], sizeof(m_core->cpr[0][COP0_BadVAddr]), "BadVAddr"); |
| 385 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Count], sizeof(m_core->cpr[0][COP0_Count]), "Count"); |
| 386 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_EntryHi], sizeof(m_core->cpr[0][COP0_EntryHi]), "EntryHi"); |
| 387 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Compare], sizeof(m_core->cpr[0][COP0_Compare]), "Compare"); |
| 388 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Status], sizeof(m_core->cpr[0][COP0_Status]), "Status"); |
| 389 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Cause], sizeof(m_core->cpr[0][COP0_Cause]), "Cause"); |
| 390 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_EPC], sizeof(m_core->cpr[0][COP0_EPC]), "EPC"); |
| 391 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_PRId], sizeof(m_core->cpr[0][COP0_PRId]), "PRId"); |
| 392 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_Config], sizeof(m_core->cpr[0][COP0_Config]), "Config"); |
| 393 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_LLAddr], sizeof(m_core->cpr[0][COP0_LLAddr]), "LLAddr"); |
| 394 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_XContext], sizeof(m_core->cpr[0][COP0_XContext]), "XContext"); |
| 395 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_ECC], sizeof(m_core->cpr[0][COP0_ECC]), "ECC"); |
| 396 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_CacheErr], sizeof(m_core->cpr[0][COP0_CacheErr]), "CacheErr"); |
| 397 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_TagLo], sizeof(m_core->cpr[0][COP0_TagLo]), "TagLo"); |
| 398 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_TagHi], sizeof(m_core->cpr[0][COP0_TagHi]), "TagHi"); |
| 399 | m_drcuml->symbol_add(&m_core->cpr[0][COP0_ErrorPC], sizeof(m_core->cpr[0][COP0_ErrorPC]), "ErrorPC"); |
| 400 | m_drcuml->symbol_add(&m_core->ccr[1][31], sizeof(m_core->cpr[1][31]), "fcr31"); |
| 401 | m_drcuml->symbol_add(&m_core->mode, sizeof(m_core->mode), "mode"); |
| 402 | m_drcuml->symbol_add(&m_core->arg0, sizeof(m_core->arg0), "arg0"); |
| 403 | m_drcuml->symbol_add(&m_core->arg1, sizeof(m_core->arg1), "arg1"); |
| 404 | m_drcuml->symbol_add(&m_core->numcycles, sizeof(m_core->numcycles), "numcycles"); |
| 405 | m_drcuml->symbol_add(&m_fpmode, sizeof(m_fpmode), "fpmode"); |
| 406 | |
| 407 | /* initialize the front-end helper */ |
| 408 | m_drcfe = auto_alloc(machine(), mips3_frontend(this, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE)); |
| 409 | |
| 410 | /* allocate memory for cache-local state and initialize it */ |
| 411 | memcpy(m_fpmode, fpmode_source, sizeof(fpmode_source)); |
| 412 | |
| 413 | /* compute the register parameters */ |
| 414 | for (int regnum = 0; regnum < 34; regnum++) |
| 287 | 415 | { |
| 288 | | mips3.lwl = lwl_le; |
| 289 | | mips3.lwr = lwr_le; |
| 290 | | mips3.swl = swl_le; |
| 291 | | mips3.swr = swr_le; |
| 292 | | mips3.ldl = ldl_le; |
| 293 | | mips3.ldr = ldr_le; |
| 294 | | mips3.sdl = sdl_le; |
| 295 | | mips3.sdr = sdr_le; |
| 416 | m_regmap[regnum] = (regnum == 0) ? uml::parameter(0) : uml::parameter::make_memory(&m_core->r[regnum]); |
| 417 | m_regmaplo[regnum] = (regnum == 0) ? uml::parameter(0) : uml::parameter::make_memory(LOPTR(&m_core->r[regnum])); |
| 296 | 418 | } |
| 419 | |
| 420 | /* if we have registers to spare, assign r2, r3, r4 to leftovers */ |
| 421 | if (!DISABLE_FAST_REGISTERS) |
| 422 | { |
| 423 | drcbe_info beinfo; |
| 424 | |
| 425 | m_drcuml->get_backend_info(beinfo); |
| 426 | if (beinfo.direct_iregs > 4) |
| 427 | { |
| 428 | m_regmap[2] = uml::I4; |
| 429 | m_regmaplo[2] = uml::I4; |
| 430 | } |
| 431 | if (beinfo.direct_iregs > 5) |
| 432 | { |
| 433 | m_regmap[3] = uml::I5; |
| 434 | m_regmaplo[3] = uml::I5; |
| 435 | } |
| 436 | if (beinfo.direct_iregs > 6) |
| 437 | { |
| 438 | m_regmap[4] = uml::I6; |
| 439 | m_regmaplo[4] = uml::I6; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /* mark the cache dirty so it is updated on next execute */ |
| 444 | m_cache_dirty = TRUE; |
| 445 | |
| 446 | |
| 447 | /* register for save states */ |
| 448 | save_item(NAME(m_core->pc)); |
| 449 | save_item(NAME(m_core->r)); |
| 450 | save_item(NAME(m_core->cpr)); |
| 451 | save_item(NAME(m_core->ccr)); |
| 452 | save_item(NAME(m_core->llbit)); |
| 453 | save_item(NAME(m_core->count_zero_time)); |
| 454 | for (int tlbindex = 0; tlbindex < m_tlbentries; tlbindex++) |
| 455 | { |
| 456 | save_item(NAME(m_tlb[tlbindex].page_mask), tlbindex); |
| 457 | save_item(NAME(m_tlb[tlbindex].entry_hi), tlbindex); |
| 458 | save_item(NAME(m_tlb[tlbindex].entry_lo), tlbindex); |
| 459 | } |
| 460 | |
| 461 | // Register state with debugger |
| 462 | state_add( MIPS3_PC, "PC", m_core->pc).formatstr("%08X"); |
| 463 | |
| 464 | #if USE_ABI_REG_NAMES |
| 465 | state_add( MIPS3_R0, "zero", m_core->r[0]).callimport().formatstr("%016X"); // Can't change R0 |
| 466 | state_add( MIPS3_R1, "at", m_core->r[1]).formatstr("%016X"); |
| 467 | state_add( MIPS3_R2, "v0", m_core->r[2]).formatstr("%016X"); |
| 468 | state_add( MIPS3_R3, "v1", m_core->r[3]).formatstr("%016X"); |
| 469 | state_add( MIPS3_R4, "a0", m_core->r[4]).formatstr("%016X"); |
| 470 | state_add( MIPS3_R5, "a1", m_core->r[5]).formatstr("%016X"); |
| 471 | state_add( MIPS3_R6, "a2", m_core->r[6]).formatstr("%016X"); |
| 472 | state_add( MIPS3_R7, "a3", m_core->r[7]).formatstr("%016X"); |
| 473 | state_add( MIPS3_R8, "t0", m_core->r[8]).formatstr("%016X"); |
| 474 | state_add( MIPS3_R9, "t1", m_core->r[9]).formatstr("%016X"); |
| 475 | state_add( MIPS3_R10, "t2", m_core->r[10]).formatstr("%016X"); |
| 476 | state_add( MIPS3_R11, "t3", m_core->r[11]).formatstr("%016X"); |
| 477 | state_add( MIPS3_R12, "t4", m_core->r[12]).formatstr("%016X"); |
| 478 | state_add( MIPS3_R13, "t5", m_core->r[13]).formatstr("%016X"); |
| 479 | state_add( MIPS3_R14, "t6", m_core->r[14]).formatstr("%016X"); |
| 480 | state_add( MIPS3_R15, "t7", m_core->r[15]).formatstr("%016X"); |
| 481 | state_add( MIPS3_R16, "s0", m_core->r[16]).formatstr("%016X"); |
| 482 | state_add( MIPS3_R17, "s1", m_core->r[17]).formatstr("%016X"); |
| 483 | state_add( MIPS3_R18, "s2", m_core->r[18]).formatstr("%016X"); |
| 484 | state_add( MIPS3_R19, "s3", m_core->r[19]).formatstr("%016X"); |
| 485 | state_add( MIPS3_R20, "s4", m_core->r[20]).formatstr("%016X"); |
| 486 | state_add( MIPS3_R21, "s5", m_core->r[21]).formatstr("%016X"); |
| 487 | state_add( MIPS3_R22, "s6", m_core->r[22]).formatstr("%016X"); |
| 488 | state_add( MIPS3_R23, "s7", m_core->r[23]).formatstr("%016X"); |
| 489 | state_add( MIPS3_R24, "t8", m_core->r[24]).formatstr("%016X"); |
| 490 | state_add( MIPS3_R25, "t9", m_core->r[25]).formatstr("%016X"); |
| 491 | state_add( MIPS3_R26, "k0", m_core->r[26]).formatstr("%016X"); |
| 492 | state_add( MIPS3_R27, "k1", m_core->r[27]).formatstr("%016X"); |
| 493 | state_add( MIPS3_R28, "gp", m_core->r[28]).formatstr("%016X"); |
| 494 | state_add( MIPS3_R29, "sp", m_core->r[29]).formatstr("%016X"); |
| 495 | state_add( MIPS3_R30, "fp", m_core->r[30]).formatstr("%016X"); |
| 496 | state_add( MIPS3_R31, "ra", m_core->r[31]).formatstr("%016X"); |
| 497 | #else |
| 498 | state_add( MIPS3_R0, "R0", m_core->r[0]).callimport().formatstr("%016X"); // Can't change R0 |
| 499 | state_add( MIPS3_R1, "R1", m_core->r[1]).formatstr("%016X"); |
| 500 | state_add( MIPS3_R2, "R2", m_core->r[2]).formatstr("%016X"); |
| 501 | state_add( MIPS3_R3, "R3", m_core->r[3]).formatstr("%016X"); |
| 502 | state_add( MIPS3_R4, "R4", m_core->r[4]).formatstr("%016X"); |
| 503 | state_add( MIPS3_R5, "R5", m_core->r[5]).formatstr("%016X"); |
| 504 | state_add( MIPS3_R6, "R6", m_core->r[6]).formatstr("%016X"); |
| 505 | state_add( MIPS3_R7, "R7", m_core->r[7]).formatstr("%016X"); |
| 506 | state_add( MIPS3_R8, "R8", m_core->r[8]).formatstr("%016X"); |
| 507 | state_add( MIPS3_R9, "R9", m_core->r[9]).formatstr("%016X"); |
| 508 | state_add( MIPS3_R10, "R10", m_core->r[10]).formatstr("%016X"); |
| 509 | state_add( MIPS3_R11, "R11", m_core->r[11]).formatstr("%016X"); |
| 510 | state_add( MIPS3_R12, "R12", m_core->r[12]).formatstr("%016X"); |
| 511 | state_add( MIPS3_R13, "R13", m_core->r[13]).formatstr("%016X"); |
| 512 | state_add( MIPS3_R14, "R14", m_core->r[14]).formatstr("%016X"); |
| 513 | state_add( MIPS3_R15, "R15", m_core->r[15]).formatstr("%016X"); |
| 514 | state_add( MIPS3_R16, "R16", m_core->r[16]).formatstr("%016X"); |
| 515 | state_add( MIPS3_R17, "R17", m_core->r[17]).formatstr("%016X"); |
| 516 | state_add( MIPS3_R18, "R18", m_core->r[18]).formatstr("%016X"); |
| 517 | state_add( MIPS3_R19, "R19", m_core->r[19]).formatstr("%016X"); |
| 518 | state_add( MIPS3_R20, "R20", m_core->r[20]).formatstr("%016X"); |
| 519 | state_add( MIPS3_R21, "R21", m_core->r[21]).formatstr("%016X"); |
| 520 | state_add( MIPS3_R22, "R22", m_core->r[22]).formatstr("%016X"); |
| 521 | state_add( MIPS3_R23, "R23", m_core->r[23]).formatstr("%016X"); |
| 522 | state_add( MIPS3_R24, "R24", m_core->r[24]).formatstr("%016X"); |
| 523 | state_add( MIPS3_R25, "R25", m_core->r[25]).formatstr("%016X"); |
| 524 | state_add( MIPS3_R26, "R26", m_core->r[26]).formatstr("%016X"); |
| 525 | state_add( MIPS3_R27, "R27", m_core->r[27]).formatstr("%016X"); |
| 526 | state_add( MIPS3_R28, "R28", m_core->r[28]).formatstr("%016X"); |
| 527 | state_add( MIPS3_R29, "R29", m_core->r[29]).formatstr("%016X"); |
| 528 | state_add( MIPS3_R30, "R30", m_core->r[30]).formatstr("%016X"); |
| 529 | state_add( MIPS3_R31, "R31", m_core->r[31]).formatstr("%016X"); |
| 530 | #endif |
| 531 | state_add( MIPS3_HI, "HI", m_core->r[REG_HI]).formatstr("%016X"); |
| 532 | state_add( MIPS3_LO, "LO", m_core->r[REG_LO]).formatstr("%016X"); |
| 533 | |
| 534 | state_add( MIPS3_CCR1_31, "CCR31", m_core->ccr[1][31]).formatstr("%08X"); |
| 535 | |
| 536 | state_add( MIPS3_FPR0, "FPR0", m_core->cpr[1][0]).formatstr("%016X"); |
| 537 | state_add( MIPS3_FPS0, "FPS0", m_core->cpr[1][0]).formatstr("%17s"); |
| 538 | state_add( MIPS3_FPD0, "FPD0", m_core->cpr[1][0]).formatstr("%17s"); |
| 539 | state_add( MIPS3_FPR1, "FPR1", m_core->cpr[1][1]).formatstr("%016X"); |
| 540 | state_add( MIPS3_FPS1, "FPS1", m_core->cpr[1][1]).formatstr("%17s"); |
| 541 | state_add( MIPS3_FPD1, "FPD1", m_core->cpr[1][1]).formatstr("%17s"); |
| 542 | state_add( MIPS3_FPR2, "FPR2", m_core->cpr[1][2]).formatstr("%016X"); |
| 543 | state_add( MIPS3_FPS2, "FPS2", m_core->cpr[1][2]).formatstr("%17s"); |
| 544 | state_add( MIPS3_FPD2, "FPD2", m_core->cpr[1][2]).formatstr("%17s"); |
| 545 | state_add( MIPS3_FPR3, "FPR3", m_core->cpr[1][3]).formatstr("%016X"); |
| 546 | state_add( MIPS3_FPS3, "FPS3", m_core->cpr[1][3]).formatstr("%17s"); |
| 547 | state_add( MIPS3_FPD3, "FPD3", m_core->cpr[1][3]).formatstr("%17s"); |
| 548 | state_add( MIPS3_FPR4, "FPR4", m_core->cpr[1][4]).formatstr("%016X"); |
| 549 | state_add( MIPS3_FPS4, "FPS4", m_core->cpr[1][4]).formatstr("%17s"); |
| 550 | state_add( MIPS3_FPD4, "FPD4", m_core->cpr[1][4]).formatstr("%17s"); |
| 551 | state_add( MIPS3_FPR5, "FPR5", m_core->cpr[1][5]).formatstr("%016X"); |
| 552 | state_add( MIPS3_FPS5, "FPS5", m_core->cpr[1][5]).formatstr("%17s"); |
| 553 | state_add( MIPS3_FPD5, "FPD5", m_core->cpr[1][5]).formatstr("%17s"); |
| 554 | state_add( MIPS3_FPR6, "FPR6", m_core->cpr[1][6]).formatstr("%016X"); |
| 555 | state_add( MIPS3_FPS6, "FPS6", m_core->cpr[1][6]).formatstr("%17s"); |
| 556 | state_add( MIPS3_FPD6, "FPD6", m_core->cpr[1][6]).formatstr("%17s"); |
| 557 | state_add( MIPS3_FPR7, "FPR7", m_core->cpr[1][7]).formatstr("%016X"); |
| 558 | state_add( MIPS3_FPS7, "FPS7", m_core->cpr[1][7]).formatstr("%17s"); |
| 559 | state_add( MIPS3_FPD7, "FPD7", m_core->cpr[1][7]).formatstr("%17s"); |
| 560 | state_add( MIPS3_FPR8, "FPR8", m_core->cpr[1][8]).formatstr("%016X"); |
| 561 | state_add( MIPS3_FPS8, "FPS8", m_core->cpr[1][8]).formatstr("%17s"); |
| 562 | state_add( MIPS3_FPD8, "FPD8", m_core->cpr[1][8]).formatstr("%17s"); |
| 563 | state_add( MIPS3_FPR9, "FPR9", m_core->cpr[1][9]).formatstr("%016X"); |
| 564 | state_add( MIPS3_FPS9, "FPS9", m_core->cpr[1][9]).formatstr("%17s"); |
| 565 | state_add( MIPS3_FPD9, "FPD9", m_core->cpr[1][9]).formatstr("%17s"); |
| 566 | state_add( MIPS3_FPR10, "FPR10", m_core->cpr[1][10]).formatstr("%016X"); |
| 567 | state_add( MIPS3_FPS10, "FPS10", m_core->cpr[1][10]).formatstr("%17s"); |
| 568 | state_add( MIPS3_FPD10, "FPD10", m_core->cpr[1][10]).formatstr("%17s"); |
| 569 | state_add( MIPS3_FPR11, "FPR11", m_core->cpr[1][11]).formatstr("%016X"); |
| 570 | state_add( MIPS3_FPS11, "FPS11", m_core->cpr[1][11]).formatstr("%17s"); |
| 571 | state_add( MIPS3_FPD11, "FPD11", m_core->cpr[1][11]).formatstr("%17s"); |
| 572 | state_add( MIPS3_FPR12, "FPR12", m_core->cpr[1][12]).formatstr("%016X"); |
| 573 | state_add( MIPS3_FPS12, "FPS12", m_core->cpr[1][12]).formatstr("%17s"); |
| 574 | state_add( MIPS3_FPD12, "FPD12", m_core->cpr[1][12]).formatstr("%17s"); |
| 575 | state_add( MIPS3_FPR13, "FPR13", m_core->cpr[1][13]).formatstr("%016X"); |
| 576 | state_add( MIPS3_FPS13, "FPS13", m_core->cpr[1][13]).formatstr("%17s"); |
| 577 | state_add( MIPS3_FPD13, "FPD13", m_core->cpr[1][13]).formatstr("%17s"); |
| 578 | state_add( MIPS3_FPR14, "FPR14", m_core->cpr[1][14]).formatstr("%016X"); |
| 579 | state_add( MIPS3_FPS14, "FPS14", m_core->cpr[1][14]).formatstr("%17s"); |
| 580 | state_add( MIPS3_FPD14, "FPD14", m_core->cpr[1][14]).formatstr("%17s"); |
| 581 | state_add( MIPS3_FPR15, "FPR15", m_core->cpr[1][15]).formatstr("%016X"); |
| 582 | state_add( MIPS3_FPS15, "FPS15", m_core->cpr[1][15]).formatstr("%17s"); |
| 583 | state_add( MIPS3_FPD15, "FPD15", m_core->cpr[1][15]).formatstr("%17s"); |
| 584 | state_add( MIPS3_FPR16, "FPR16", m_core->cpr[1][16]).formatstr("%016X"); |
| 585 | state_add( MIPS3_FPS16, "FPS16", m_core->cpr[1][16]).formatstr("%17s"); |
| 586 | state_add( MIPS3_FPD16, "FPD16", m_core->cpr[1][16]).formatstr("%17s"); |
| 587 | state_add( MIPS3_FPR17, "FPR17", m_core->cpr[1][17]).formatstr("%016X"); |
| 588 | state_add( MIPS3_FPS17, "FPS17", m_core->cpr[1][17]).formatstr("%17s"); |
| 589 | state_add( MIPS3_FPD17, "FPD17", m_core->cpr[1][17]).formatstr("%17s"); |
| 590 | state_add( MIPS3_FPR18, "FPR18", m_core->cpr[1][18]).formatstr("%016X"); |
| 591 | state_add( MIPS3_FPS18, "FPS18", m_core->cpr[1][18]).formatstr("%17s"); |
| 592 | state_add( MIPS3_FPD18, "FPD18", m_core->cpr[1][18]).formatstr("%17s"); |
| 593 | state_add( MIPS3_FPR19, "FPR19", m_core->cpr[1][19]).formatstr("%016X"); |
| 594 | state_add( MIPS3_FPS19, "FPS19", m_core->cpr[1][19]).formatstr("%17s"); |
| 595 | state_add( MIPS3_FPD19, "FPD19", m_core->cpr[1][19]).formatstr("%17s"); |
| 596 | state_add( MIPS3_FPR20, "FPR20", m_core->cpr[1][20]).formatstr("%016X"); |
| 597 | state_add( MIPS3_FPS20, "FPS20", m_core->cpr[1][20]).formatstr("%17s"); |
| 598 | state_add( MIPS3_FPD20, "FPD20", m_core->cpr[1][20]).formatstr("%17s"); |
| 599 | state_add( MIPS3_FPR21, "FPR21", m_core->cpr[1][21]).formatstr("%016X"); |
| 600 | state_add( MIPS3_FPS21, "FPS21", m_core->cpr[1][21]).formatstr("%17s"); |
| 601 | state_add( MIPS3_FPD21, "FPD21", m_core->cpr[1][21]).formatstr("%17s"); |
| 602 | state_add( MIPS3_FPR22, "FPR22", m_core->cpr[1][22]).formatstr("%016X"); |
| 603 | state_add( MIPS3_FPS22, "FPS22", m_core->cpr[1][22]).formatstr("%17s"); |
| 604 | state_add( MIPS3_FPD22, "FPD22", m_core->cpr[1][22]).formatstr("%17s"); |
| 605 | state_add( MIPS3_FPR23, "FPR23", m_core->cpr[1][23]).formatstr("%016X"); |
| 606 | state_add( MIPS3_FPS23, "FPS23", m_core->cpr[1][23]).formatstr("%17s"); |
| 607 | state_add( MIPS3_FPD23, "FPD23", m_core->cpr[1][23]).formatstr("%17s"); |
| 608 | state_add( MIPS3_FPR24, "FPR24", m_core->cpr[1][24]).formatstr("%016X"); |
| 609 | state_add( MIPS3_FPS24, "FPS24", m_core->cpr[1][24]).formatstr("%17s"); |
| 610 | state_add( MIPS3_FPD24, "FPD24", m_core->cpr[1][24]).formatstr("%17s"); |
| 611 | state_add( MIPS3_FPR25, "FPR25", m_core->cpr[1][25]).formatstr("%016X"); |
| 612 | state_add( MIPS3_FPS25, "FPS25", m_core->cpr[1][25]).formatstr("%17s"); |
| 613 | state_add( MIPS3_FPD25, "FPD25", m_core->cpr[1][25]).formatstr("%17s"); |
| 614 | state_add( MIPS3_FPR26, "FPR26", m_core->cpr[1][26]).formatstr("%016X"); |
| 615 | state_add( MIPS3_FPS26, "FPS26", m_core->cpr[1][26]).formatstr("%17s"); |
| 616 | state_add( MIPS3_FPD26, "FPD26", m_core->cpr[1][26]).formatstr("%17s"); |
| 617 | state_add( MIPS3_FPR27, "FPR27", m_core->cpr[1][27]).formatstr("%016X"); |
| 618 | state_add( MIPS3_FPS27, "FPS27", m_core->cpr[1][27]).formatstr("%17s"); |
| 619 | state_add( MIPS3_FPD27, "FPD27", m_core->cpr[1][27]).formatstr("%17s"); |
| 620 | state_add( MIPS3_FPR28, "FPR28", m_core->cpr[1][28]).formatstr("%016X"); |
| 621 | state_add( MIPS3_FPS28, "FPS28", m_core->cpr[1][28]).formatstr("%17s"); |
| 622 | state_add( MIPS3_FPD28, "FPD28", m_core->cpr[1][28]).formatstr("%17s"); |
| 623 | state_add( MIPS3_FPR29, "FPR29", m_core->cpr[1][29]).formatstr("%016X"); |
| 624 | state_add( MIPS3_FPS29, "FPS29", m_core->cpr[1][29]).formatstr("%17s"); |
| 625 | state_add( MIPS3_FPD29, "FPD29", m_core->cpr[1][29]).formatstr("%17s"); |
| 626 | state_add( MIPS3_FPR30, "FPR30", m_core->cpr[1][30]).formatstr("%016X"); |
| 627 | state_add( MIPS3_FPS30, "FPS30", m_core->cpr[1][30]).formatstr("%17s"); |
| 628 | state_add( MIPS3_FPD30, "FPD30", m_core->cpr[1][30]).formatstr("%17s"); |
| 629 | state_add( MIPS3_FPR31, "FPR31", m_core->cpr[1][31]).formatstr("%016X"); |
| 630 | state_add( MIPS3_FPS31, "FPS31", m_core->cpr[1][31]).formatstr("%17s"); |
| 631 | state_add( MIPS3_FPD31, "FPD31", m_core->cpr[1][31]).formatstr("%17s"); |
| 632 | |
| 633 | state_add( MIPS3_SR, "SR", m_core->cpr[0][COP0_Status]).formatstr("%08X"); |
| 634 | state_add( MIPS3_EPC, "EPC", m_core->cpr[0][COP0_EPC]).formatstr("%08X"); |
| 635 | state_add( MIPS3_CAUSE, "Cause", m_core->cpr[0][COP0_Cause]).formatstr("%08X"); |
| 636 | state_add( MIPS3_COUNT, "Count", m_debugger_temp).callexport().formatstr("%08X"); |
| 637 | state_add( MIPS3_COMPARE, "Compare", m_core->cpr[0][COP0_Compare]).formatstr("%08X"); |
| 638 | state_add( MIPS3_INDEX, "Index", m_core->cpr[0][COP0_Index]).formatstr("%08X"); |
| 639 | state_add( MIPS3_RANDOM, "Random", m_core->cpr[0][COP0_Random]).formatstr("%08X"); |
| 640 | state_add( MIPS3_ENTRYHI, "EntryHi", m_core->cpr[0][COP0_EntryHi]).formatstr("%016X"); |
| 641 | state_add( MIPS3_ENTRYLO0, "EntryLo0", m_core->cpr[0][COP0_EntryLo0]).formatstr("%016X"); |
| 642 | state_add( MIPS3_ENTRYLO1, "EntryLo1", m_core->cpr[0][COP0_EntryLo1]).formatstr("%016X"); |
| 643 | state_add( MIPS3_PAGEMASK, "PageMask", m_core->cpr[0][COP0_PageMask]).formatstr("%016X"); |
| 644 | state_add( MIPS3_WIRED, "Wired", m_core->cpr[0][COP0_Wired]).formatstr("%08X"); |
| 645 | state_add( MIPS3_BADVADDR, "BadVAddr", m_core->cpr[0][COP0_BadVAddr]).formatstr("%08X"); |
| 646 | |
| 647 | state_add( STATE_GENPC, "GENPC", m_core->pc).noshow(); |
| 648 | state_add( STATE_GENSP, "GENSP", m_core->r[31]).noshow(); |
| 649 | state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%1s").noshow(); |
| 650 | |
| 651 | m_icountptr = &m_core->icount; |
| 297 | 652 | } |
| 298 | 653 | |
| 299 | 654 | |
| 300 | | static CPU_TRANSLATE( mips3 ) |
| 655 | void mips3_device::state_export(const device_state_entry &entry) |
| 301 | 656 | { |
| 302 | | /* common translate */ |
| 303 | | return mips3com_translate_address(&mips3.core, space, intention, address); |
| 657 | switch (entry.index()) |
| 658 | { |
| 659 | case MIPS3_COUNT: |
| 660 | m_debugger_temp = (total_cycles() - m_core->count_zero_time) / 2; |
| 661 | break; |
| 662 | } |
| 304 | 663 | } |
| 305 | 664 | |
| 306 | 665 | |
| 307 | | CPU_DISASSEMBLE( mips3 ) |
| 666 | void mips3_device::state_string_export(const device_state_entry &entry, astring &string) |
| 308 | 667 | { |
| 309 | | /* common disassemble */ |
| 310 | | return mips3com_dasm(&mips3.core, buffer, pc, oprom, opram); |
| 668 | switch (entry.index()) |
| 669 | { |
| 670 | case MIPS3_FPS0: |
| 671 | string.printf("!%16g", *(float *)&m_core->cpr[1][0]); |
| 672 | break; |
| 673 | |
| 674 | case MIPS3_FPD0: |
| 675 | string.printf("!%16g", *(double *)&m_core->cpr[1][0]); |
| 676 | break; |
| 677 | |
| 678 | case MIPS3_FPS1: |
| 679 | string.printf("!%16g", *(float *)&m_core->cpr[1][1]); |
| 680 | break; |
| 681 | |
| 682 | case MIPS3_FPD1: |
| 683 | string.printf("!%16g", *(double *)&m_core->cpr[1][1]); |
| 684 | break; |
| 685 | |
| 686 | case MIPS3_FPS2: |
| 687 | string.printf("!%16g", *(float *)&m_core->cpr[1][2]); |
| 688 | break; |
| 689 | |
| 690 | case MIPS3_FPD2: |
| 691 | string.printf("!%16g", *(double *)&m_core->cpr[1][2]); |
| 692 | break; |
| 693 | |
| 694 | case MIPS3_FPS3: |
| 695 | string.printf("!%16g", *(float *)&m_core->cpr[1][3]); |
| 696 | break; |
| 697 | |
| 698 | case MIPS3_FPD3: |
| 699 | string.printf("!%16g", *(double *)&m_core->cpr[1][3]); |
| 700 | break; |
| 701 | |
| 702 | case MIPS3_FPS4: |
| 703 | string.printf("!%16g", *(float *)&m_core->cpr[1][4]); |
| 704 | break; |
| 705 | |
| 706 | case MIPS3_FPD4: |
| 707 | string.printf("!%16g", *(double *)&m_core->cpr[1][4]); |
| 708 | break; |
| 709 | |
| 710 | case MIPS3_FPS5: |
| 711 | string.printf("!%16g", *(float *)&m_core->cpr[1][5]); |
| 712 | break; |
| 713 | |
| 714 | case MIPS3_FPD5: |
| 715 | string.printf("!%16g", *(double *)&m_core->cpr[1][5]); |
| 716 | break; |
| 717 | |
| 718 | case MIPS3_FPS6: |
| 719 | string.printf("!%16g", *(float *)&m_core->cpr[1][6]); |
| 720 | break; |
| 721 | |
| 722 | case MIPS3_FPD6: |
| 723 | string.printf("!%16g", *(double *)&m_core->cpr[1][6]); |
| 724 | break; |
| 725 | |
| 726 | case MIPS3_FPS7: |
| 727 | string.printf("!%16g", *(float *)&m_core->cpr[1][7]); |
| 728 | break; |
| 729 | |
| 730 | case MIPS3_FPD7: |
| 731 | string.printf("!%16g", *(double *)&m_core->cpr[1][7]); |
| 732 | break; |
| 733 | |
| 734 | case MIPS3_FPS8: |
| 735 | string.printf("!%16g", *(float *)&m_core->cpr[1][8]); |
| 736 | break; |
| 737 | |
| 738 | case MIPS3_FPD8: |
| 739 | string.printf("!%16g", *(double *)&m_core->cpr[1][8]); |
| 740 | break; |
| 741 | |
| 742 | case MIPS3_FPS9: |
| 743 | string.printf("!%16g", *(float *)&m_core->cpr[1][9]); |
| 744 | break; |
| 745 | |
| 746 | case MIPS3_FPD9: |
| 747 | string.printf("!%16g", *(double *)&m_core->cpr[1][9]); |
| 748 | break; |
| 749 | |
| 750 | case MIPS3_FPS10: |
| 751 | string.printf("!%16g", *(float *)&m_core->cpr[1][10]); |
| 752 | break; |
| 753 | |
| 754 | case MIPS3_FPD10: |
| 755 | string.printf("!%16g", *(double *)&m_core->cpr[1][10]); |
| 756 | break; |
| 757 | |
| 758 | case MIPS3_FPS11: |
| 759 | string.printf("!%16g", *(float *)&m_core->cpr[1][11]); |
| 760 | break; |
| 761 | |
| 762 | case MIPS3_FPD11: |
| 763 | string.printf("!%16g", *(double *)&m_core->cpr[1][11]); |
| 764 | break; |
| 765 | |
| 766 | case MIPS3_FPS12: |
| 767 | string.printf("!%16g", *(float *)&m_core->cpr[1][12]); |
| 768 | break; |
| 769 | |
| 770 | case MIPS3_FPD12: |
| 771 | string.printf("!%16g", *(double *)&m_core->cpr[1][12]); |
| 772 | break; |
| 773 | |
| 774 | case MIPS3_FPS13: |
| 775 | string.printf("!%16g", *(float *)&m_core->cpr[1][13]); |
| 776 | break; |
| 777 | |
| 778 | case MIPS3_FPD13: |
| 779 | string.printf("!%16g", *(double *)&m_core->cpr[1][13]); |
| 780 | break; |
| 781 | |
| 782 | case MIPS3_FPS14: |
| 783 | string.printf("!%16g", *(float *)&m_core->cpr[1][14]); |
| 784 | break; |
| 785 | |
| 786 | case MIPS3_FPD14: |
| 787 | string.printf("!%16g", *(double *)&m_core->cpr[1][14]); |
| 788 | break; |
| 789 | |
| 790 | case MIPS3_FPS15: |
| 791 | string.printf("!%16g", *(float *)&m_core->cpr[1][15]); |
| 792 | break; |
| 793 | |
| 794 | case MIPS3_FPD15: |
| 795 | string.printf("!%16g", *(double *)&m_core->cpr[1][15]); |
| 796 | break; |
| 797 | |
| 798 | case MIPS3_FPS16: |
| 799 | string.printf("!%16g", *(float *)&m_core->cpr[1][16]); |
| 800 | break; |
| 801 | |
| 802 | case MIPS3_FPD16: |
| 803 | string.printf("!%16g", *(double *)&m_core->cpr[1][16]); |
| 804 | break; |
| 805 | |
| 806 | case MIPS3_FPS17: |
| 807 | string.printf("!%16g", *(float *)&m_core->cpr[1][17]); |
| 808 | break; |
| 809 | |
| 810 | case MIPS3_FPD17: |
| 811 | string.printf("!%16g", *(double *)&m_core->cpr[1][17]); |
| 812 | break; |
| 813 | |
| 814 | case MIPS3_FPS18: |
| 815 | string.printf("!%16g", *(float *)&m_core->cpr[1][18]); |
| 816 | break; |
| 817 | |
| 818 | case MIPS3_FPD18: |
| 819 | string.printf("!%16g", *(double *)&m_core->cpr[1][18]); |
| 820 | break; |
| 821 | |
| 822 | case MIPS3_FPS19: |
| 823 | string.printf("!%16g", *(float *)&m_core->cpr[1][19]); |
| 824 | break; |
| 825 | |
| 826 | case MIPS3_FPD19: |
| 827 | string.printf("!%16g", *(double *)&m_core->cpr[1][19]); |
| 828 | break; |
| 829 | |
| 830 | case MIPS3_FPS20: |
| 831 | string.printf("!%16g", *(float *)&m_core->cpr[1][20]); |
| 832 | break; |
| 833 | |
| 834 | case MIPS3_FPD20: |
| 835 | string.printf("!%16g", *(double *)&m_core->cpr[1][20]); |
| 836 | break; |
| 837 | |
| 838 | case MIPS3_FPS21: |
| 839 | string.printf("!%16g", *(float *)&m_core->cpr[1][21]); |
| 840 | break; |
| 841 | |
| 842 | case MIPS3_FPD21: |
| 843 | string.printf("!%16g", *(double *)&m_core->cpr[1][21]); |
| 844 | break; |
| 845 | |
| 846 | case MIPS3_FPS22: |
| 847 | string.printf("!%16g", *(float *)&m_core->cpr[1][22]); |
| 848 | break; |
| 849 | |
| 850 | case MIPS3_FPD22: |
| 851 | string.printf("!%16g", *(double *)&m_core->cpr[1][22]); |
| 852 | break; |
| 853 | |
| 854 | case MIPS3_FPS23: |
| 855 | string.printf("!%16g", *(float *)&m_core->cpr[1][23]); |
| 856 | break; |
| 857 | |
| 858 | case MIPS3_FPD23: |
| 859 | string.printf("!%16g", *(double *)&m_core->cpr[1][23]); |
| 860 | break; |
| 861 | |
| 862 | case MIPS3_FPS24: |
| 863 | string.printf("!%16g", *(float *)&m_core->cpr[1][24]); |
| 864 | break; |
| 865 | |
| 866 | case MIPS3_FPD24: |
| 867 | string.printf("!%16g", *(double *)&m_core->cpr[1][24]); |
| 868 | break; |
| 869 | |
| 870 | case MIPS3_FPS25: |
| 871 | string.printf("!%16g", *(float *)&m_core->cpr[1][25]); |
| 872 | break; |
| 873 | |
| 874 | case MIPS3_FPD25: |
| 875 | string.printf("!%16g", *(double *)&m_core->cpr[1][25]); |
| 876 | break; |
| 877 | |
| 878 | case MIPS3_FPS26: |
| 879 | string.printf("!%16g", *(float *)&m_core->cpr[1][26]); |
| 880 | break; |
| 881 | |
| 882 | case MIPS3_FPD26: |
| 883 | string.printf("!%16g", *(double *)&m_core->cpr[1][26]); |
| 884 | break; |
| 885 | |
| 886 | case MIPS3_FPS27: |
| 887 | string.printf("!%16g", *(float *)&m_core->cpr[1][27]); |
| 888 | break; |
| 889 | |
| 890 | case MIPS3_FPD27: |
| 891 | string.printf("!%16g", *(double *)&m_core->cpr[1][27]); |
| 892 | break; |
| 893 | |
| 894 | case MIPS3_FPS28: |
| 895 | string.printf("!%16g", *(float *)&m_core->cpr[1][28]); |
| 896 | break; |
| 897 | |
| 898 | case MIPS3_FPD28: |
| 899 | string.printf("!%16g", *(double *)&m_core->cpr[1][28]); |
| 900 | break; |
| 901 | |
| 902 | case MIPS3_FPS29: |
| 903 | string.printf("!%16g", *(float *)&m_core->cpr[1][29]); |
| 904 | break; |
| 905 | |
| 906 | case MIPS3_FPD29: |
| 907 | string.printf("!%16g", *(double *)&m_core->cpr[1][29]); |
| 908 | break; |
| 909 | |
| 910 | case MIPS3_FPS30: |
| 911 | string.printf("!%16g", *(float *)&m_core->cpr[1][30]); |
| 912 | break; |
| 913 | |
| 914 | case MIPS3_FPD30: |
| 915 | string.printf("!%16g", *(double *)&m_core->cpr[1][30]); |
| 916 | break; |
| 917 | |
| 918 | case MIPS3_FPS31: |
| 919 | string.printf("!%16g", *(float *)&m_core->cpr[1][31]); |
| 920 | break; |
| 921 | |
| 922 | case MIPS3_FPD31: |
| 923 | string.printf("!%16g", *(double *)&m_core->cpr[1][31]); |
| 924 | break; |
| 925 | |
| 926 | case STATE_GENFLAGS: |
| 927 | string.printf(" "); |
| 928 | break; |
| 929 | } |
| 311 | 930 | } |
| 312 | 931 | |
| 313 | 932 | |
| 933 | void mips3_device::device_reset() |
| 934 | { |
| 935 | /* common reset */ |
| 936 | m_nextpc = ~0; |
| 937 | memset(m_cf, 0, sizeof(m_cf)); |
| 314 | 938 | |
| 939 | /* initialize the state */ |
| 940 | m_core->pc = 0xbfc00000; |
| 941 | m_core->cpr[0][COP0_Status] = SR_BEV | SR_ERL; |
| 942 | m_core->cpr[0][COP0_Wired] = 0; |
| 943 | m_core->cpr[0][COP0_Compare] = 0xffffffff; |
| 944 | m_core->cpr[0][COP0_Count] = 0; |
| 945 | m_core->cpr[0][COP0_Config] = compute_config_register(); |
| 946 | m_core->cpr[0][COP0_PRId] = compute_prid_register(); |
| 947 | m_core->count_zero_time = total_cycles(); |
| 948 | |
| 949 | /* initialize the TLB state */ |
| 950 | for (int tlbindex = 0; tlbindex < m_tlbentries; tlbindex++) |
| 951 | { |
| 952 | mips3_tlb_entry *entry = &m_tlb[tlbindex]; |
| 953 | entry->page_mask = 0; |
| 954 | entry->entry_hi = 0xffffffff; |
| 955 | entry->entry_lo[0] = 0xfffffff8; |
| 956 | entry->entry_lo[1] = 0xfffffff8; |
| 957 | vtlb_load(m_vtlb, 2 * tlbindex + 0, 0, 0, 0); |
| 958 | vtlb_load(m_vtlb, 2 * tlbindex + 1, 0, 0, 0); |
| 959 | } |
| 960 | |
| 961 | /* load the fixed TLB range */ |
| 962 | vtlb_load(m_vtlb, 2 * m_tlbentries + 0, (0xa0000000 - 0x80000000) >> MIPS3_MIN_PAGE_SHIFT, 0x80000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID); |
| 963 | vtlb_load(m_vtlb, 2 * m_tlbentries + 1, (0xc0000000 - 0xa0000000) >> MIPS3_MIN_PAGE_SHIFT, 0xa0000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID); |
| 964 | |
| 965 | m_core->mode = (MODE_KERNEL << 1) | 0; |
| 966 | m_cache_dirty = TRUE; |
| 967 | m_interrupt_cycles = 0; |
| 968 | } |
| 969 | |
| 970 | |
| 971 | bool mips3_device::memory_translate(address_spacenum spacenum, int intention, offs_t &address) |
| 972 | { |
| 973 | /* only applies to the program address space */ |
| 974 | if (spacenum == AS_PROGRAM) |
| 975 | { |
| 976 | const vtlb_entry *table = vtlb_table(m_vtlb); |
| 977 | vtlb_entry entry = table[address >> MIPS3_MIN_PAGE_SHIFT]; |
| 978 | if ((entry & (1 << (intention & (TRANSLATE_TYPE_MASK | TRANSLATE_USER_MASK)))) == 0) |
| 979 | return false; |
| 980 | address = (entry & ~MIPS3_MIN_PAGE_MASK) | (address & MIPS3_MIN_PAGE_MASK); |
| 981 | } |
| 982 | return true; |
| 983 | } |
| 984 | |
| 985 | |
| 986 | offs_t mips3_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 987 | { |
| 988 | extern unsigned dasmmips3(char *, unsigned, UINT32); |
| 989 | UINT32 op = *(UINT32 *)oprom; |
| 990 | if (m_bigendian) |
| 991 | op = BIG_ENDIANIZE_INT32(op); |
| 992 | else |
| 993 | op = LITTLE_ENDIANIZE_INT32(op); |
| 994 | return dasmmips3(buffer, pc, op); |
| 995 | } |
| 996 | |
| 997 | |
| 998 | |
| 315 | 999 | /*************************************************************************** |
| 316 | 1000 | TLB HANDLING |
| 317 | 1001 | ***************************************************************************/ |
| 318 | 1002 | |
| 319 | | INLINE int RBYTE(offs_t address, UINT32 *result) |
| 1003 | inline int mips3_device::RBYTE(offs_t address, UINT32 *result) |
| 320 | 1004 | { |
| 321 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1005 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 322 | 1006 | if (tlbval & VTLB_READ_ALLOWED) |
| 323 | 1007 | { |
| 324 | | *result = (*mips3.core.memory.read_byte)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 1008 | *result = (*m_memory.read_byte)(*m_program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 325 | 1009 | } |
| 326 | 1010 | else |
| 327 | 1011 | { |
| r30757 | r30758 | |
| 340 | 1024 | } |
| 341 | 1025 | |
| 342 | 1026 | |
| 343 | | INLINE int RHALF(offs_t address, UINT32 *result) |
| 1027 | inline int mips3_device::RHALF(offs_t address, UINT32 *result) |
| 344 | 1028 | { |
| 345 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1029 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 346 | 1030 | if (tlbval & VTLB_READ_ALLOWED) |
| 347 | 1031 | { |
| 348 | | *result = (*mips3.core.memory.read_word)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 1032 | *result = (*m_memory.read_word)(*m_program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 349 | 1033 | } |
| 350 | 1034 | else |
| 351 | 1035 | { |
| r30757 | r30758 | |
| 364 | 1048 | } |
| 365 | 1049 | |
| 366 | 1050 | |
| 367 | | INLINE int RWORD(offs_t address, UINT32 *result) |
| 1051 | inline int mips3_device::RWORD(offs_t address, UINT32 *result) |
| 368 | 1052 | { |
| 369 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1053 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 370 | 1054 | if (tlbval & VTLB_READ_ALLOWED) |
| 371 | 1055 | { |
| 372 | | *result = (*mips3.core.memory.read_dword)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 1056 | *result = (*m_memory.read_dword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 373 | 1057 | } |
| 374 | 1058 | else |
| 375 | 1059 | { |
| r30757 | r30758 | |
| 388 | 1072 | } |
| 389 | 1073 | |
| 390 | 1074 | |
| 391 | | INLINE int RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask) |
| 1075 | inline int mips3_device::RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask) |
| 392 | 1076 | { |
| 393 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1077 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 394 | 1078 | if (tlbval & VTLB_READ_ALLOWED) |
| 395 | 1079 | { |
| 396 | | *result = (*mips3.core.memory.read_dword_masked)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask); |
| 1080 | *result = (*m_memory.read_dword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask); |
| 397 | 1081 | } |
| 398 | 1082 | else |
| 399 | 1083 | { |
| r30757 | r30758 | |
| 412 | 1096 | } |
| 413 | 1097 | |
| 414 | 1098 | |
| 415 | | INLINE int RDOUBLE(offs_t address, UINT64 *result) |
| 1099 | inline int mips3_device::RDOUBLE(offs_t address, UINT64 *result) |
| 416 | 1100 | { |
| 417 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1101 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 418 | 1102 | if (tlbval & VTLB_READ_ALLOWED) |
| 419 | 1103 | { |
| 420 | | *result = (*mips3.core.memory.read_qword)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 1104 | *result = (*m_memory.read_qword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff)); |
| 421 | 1105 | } |
| 422 | 1106 | else |
| 423 | 1107 | { |
| r30757 | r30758 | |
| 436 | 1120 | } |
| 437 | 1121 | |
| 438 | 1122 | |
| 439 | | INLINE int RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask) |
| 1123 | inline int mips3_device::RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask) |
| 440 | 1124 | { |
| 441 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1125 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 442 | 1126 | if (tlbval & VTLB_READ_ALLOWED) |
| 443 | 1127 | { |
| 444 | | *result = (*mips3.core.memory.read_qword_masked)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask); |
| 1128 | *result = (*m_memory.read_qword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask); |
| 445 | 1129 | } |
| 446 | 1130 | else |
| 447 | 1131 | { |
| r30757 | r30758 | |
| 460 | 1144 | } |
| 461 | 1145 | |
| 462 | 1146 | |
| 463 | | INLINE void WBYTE(offs_t address, UINT8 data) |
| 1147 | inline void mips3_device::WBYTE(offs_t address, UINT8 data) |
| 464 | 1148 | { |
| 465 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1149 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 466 | 1150 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 467 | 1151 | { |
| 468 | | (*mips3.core.memory.write_byte)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 1152 | (*m_memory.write_byte)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 469 | 1153 | } |
| 470 | 1154 | else |
| 471 | 1155 | { |
| r30757 | r30758 | |
| 485 | 1169 | } |
| 486 | 1170 | |
| 487 | 1171 | |
| 488 | | INLINE void WHALF(offs_t address, UINT16 data) |
| 1172 | inline void mips3_device::WHALF(offs_t address, UINT16 data) |
| 489 | 1173 | { |
| 490 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1174 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 491 | 1175 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 492 | 1176 | { |
| 493 | | (*mips3.core.memory.write_word)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 1177 | (*m_memory.write_word)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 494 | 1178 | } |
| 495 | 1179 | else |
| 496 | 1180 | { |
| r30757 | r30758 | |
| 510 | 1194 | } |
| 511 | 1195 | |
| 512 | 1196 | |
| 513 | | INLINE void WWORD(offs_t address, UINT32 data) |
| 1197 | inline void mips3_device::WWORD(offs_t address, UINT32 data) |
| 514 | 1198 | { |
| 515 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1199 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 516 | 1200 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 517 | 1201 | { |
| 518 | | (*mips3.core.memory.write_dword)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 1202 | (*m_memory.write_dword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 519 | 1203 | } |
| 520 | 1204 | else |
| 521 | 1205 | { |
| r30757 | r30758 | |
| 535 | 1219 | } |
| 536 | 1220 | |
| 537 | 1221 | |
| 538 | | INLINE void WWORD_MASKED(offs_t address, UINT32 data, UINT32 mem_mask) |
| 1222 | inline void mips3_device::WWORD_MASKED(offs_t address, UINT32 data, UINT32 mem_mask) |
| 539 | 1223 | { |
| 540 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1224 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 541 | 1225 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 542 | 1226 | { |
| 543 | | (*mips3.core.memory.write_dword_masked)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data, mem_mask); |
| 1227 | (*m_memory.write_dword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data, mem_mask); |
| 544 | 1228 | } |
| 545 | 1229 | else |
| 546 | 1230 | { |
| r30757 | r30758 | |
| 560 | 1244 | } |
| 561 | 1245 | |
| 562 | 1246 | |
| 563 | | INLINE void WDOUBLE(offs_t address, UINT64 data) |
| 1247 | inline void mips3_device::WDOUBLE(offs_t address, UINT64 data) |
| 564 | 1248 | { |
| 565 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1249 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 566 | 1250 | //printf("%08x: %08x\n", (UINT32)address, (UINT32)tlbval); |
| 567 | 1251 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 568 | 1252 | { |
| 569 | | (*mips3.core.memory.write_qword)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 1253 | (*m_memory.write_qword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data); |
| 570 | 1254 | } |
| 571 | 1255 | else |
| 572 | 1256 | { |
| r30757 | r30758 | |
| 586 | 1270 | } |
| 587 | 1271 | |
| 588 | 1272 | |
| 589 | | INLINE void WDOUBLE_MASKED(offs_t address, UINT64 data, UINT64 mem_mask) |
| 1273 | inline void mips3_device::WDOUBLE_MASKED(offs_t address, UINT64 data, UINT64 mem_mask) |
| 590 | 1274 | { |
| 591 | | UINT32 tlbval = mips3.tlb_table[address >> 12]; |
| 1275 | UINT32 tlbval = m_tlb_table[address >> 12]; |
| 592 | 1276 | if (tlbval & VTLB_WRITE_ALLOWED) |
| 593 | 1277 | { |
| 594 | | (*mips3.core.memory.write_qword_masked)(*mips3.core.program, (tlbval & ~0xfff) | (address & 0xfff), data, mem_mask); |
| 1278 | (*m_memory.write_qword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data, mem_mask); |
| 595 | 1279 | } |
| 596 | 1280 | else |
| 597 | 1281 | { |
| r30757 | r30758 | |
| 616 | 1300 | COP0 (SYSTEM) EXECUTION HANDLING |
| 617 | 1301 | ***************************************************************************/ |
| 618 | 1302 | |
| 619 | | INLINE UINT64 get_cop0_reg(int idx) |
| 1303 | inline UINT64 mips3_device::get_cop0_reg(int idx) |
| 620 | 1304 | { |
| 621 | 1305 | if (idx == COP0_Count) |
| 622 | 1306 | { |
| 623 | 1307 | /* it doesn't really take 250 cycles to read this register, but it helps speed */ |
| 624 | 1308 | /* up loops that hammer on it */ |
| 625 | | if (mips3.core.icount >= MIPS3_COUNT_READ_CYCLES) |
| 626 | | mips3.core.icount -= MIPS3_COUNT_READ_CYCLES; |
| 1309 | if (m_core->icount >= MIPS3_COUNT_READ_CYCLES) |
| 1310 | m_core->icount -= MIPS3_COUNT_READ_CYCLES; |
| 627 | 1311 | else |
| 628 | | mips3.core.icount = 0; |
| 629 | | return (UINT32)((mips3.core.device->total_cycles() - mips3.core.count_zero_time) / 2); |
| 1312 | m_core->icount = 0; |
| 1313 | return (UINT32)((total_cycles() - m_core->count_zero_time) / 2); |
| 630 | 1314 | } |
| 631 | 1315 | else if (idx == COP0_Cause) |
| 632 | 1316 | { |
| 633 | 1317 | /* it doesn't really take 250 cycles to read this register, but it helps speed */ |
| 634 | 1318 | /* up loops that hammer on it */ |
| 635 | | if (mips3.core.icount >= MIPS3_CAUSE_READ_CYCLES) |
| 636 | | mips3.core.icount -= MIPS3_CAUSE_READ_CYCLES; |
| 1319 | if (m_core->icount >= MIPS3_CAUSE_READ_CYCLES) |
| 1320 | m_core->icount -= MIPS3_CAUSE_READ_CYCLES; |
| 637 | 1321 | else |
| 638 | | mips3.core.icount = 0; |
| 1322 | m_core->icount = 0; |
| 639 | 1323 | } |
| 640 | 1324 | else if (idx == COP0_Random) |
| 641 | 1325 | { |
| 642 | | int wired = mips3.core.cpr[0][COP0_Wired] & 0x3f; |
| 1326 | int wired = m_core->cpr[0][COP0_Wired] & 0x3f; |
| 643 | 1327 | int range = 48 - wired; |
| 644 | 1328 | if (range > 0) |
| 645 | | return ((mips3.core.device->total_cycles() - mips3.core.count_zero_time) % range + wired) & 0x3f; |
| 1329 | return ((total_cycles() - m_core->count_zero_time) % range + wired) & 0x3f; |
| 646 | 1330 | else |
| 647 | 1331 | return 47; |
| 648 | 1332 | } |
| 649 | | return mips3.core.cpr[0][idx]; |
| 1333 | return m_core->cpr[0][idx]; |
| 650 | 1334 | } |
| 651 | 1335 | |
| 652 | | INLINE void set_cop0_reg(int idx, UINT64 val) |
| 1336 | inline void mips3_device::set_cop0_reg(int idx, UINT64 val) |
| 653 | 1337 | { |
| 654 | 1338 | switch (idx) |
| 655 | 1339 | { |
| r30757 | r30758 | |
| 658 | 1342 | if (CAUSE & 0x300) |
| 659 | 1343 | { |
| 660 | 1344 | /* if we're in a delay slot, propogate the target PC before generating the exception */ |
| 661 | | if (mips3.nextpc != ~0) |
| 1345 | if (m_nextpc != ~0) |
| 662 | 1346 | { |
| 663 | | mips3.core.pc = mips3.nextpc; |
| 664 | | mips3.nextpc = ~0; |
| 1347 | m_core->pc = m_nextpc; |
| 1348 | m_nextpc = ~0; |
| 665 | 1349 | } |
| 666 | 1350 | generate_exception(EXCEPTION_INTERRUPT, 0); |
| 667 | 1351 | } |
| r30757 | r30758 | |
| 670 | 1354 | case COP0_Status: |
| 671 | 1355 | { |
| 672 | 1356 | /* update interrupts and cycle counting */ |
| 673 | | UINT32 diff = mips3.core.cpr[0][idx] ^ val; |
| 1357 | UINT32 diff = m_core->cpr[0][idx] ^ val; |
| 674 | 1358 | // if (val & 0xe0) |
| 675 | 1359 | // fatalerror("System set 64-bit addressing mode, SR=%08X\n", val); |
| 676 | | mips3.core.cpr[0][idx] = val; |
| 1360 | m_core->cpr[0][idx] = val; |
| 677 | 1361 | if (diff & 0x8000) |
| 678 | | mips3com_update_cycle_counting(&mips3.core); |
| 1362 | mips3com_update_cycle_counting(); |
| 679 | 1363 | check_irqs(); |
| 680 | 1364 | break; |
| 681 | 1365 | } |
| 682 | 1366 | |
| 683 | 1367 | case COP0_Count: |
| 684 | | mips3.core.cpr[0][idx] = val; |
| 685 | | mips3.core.count_zero_time = mips3.core.device->total_cycles() - ((UINT64)(UINT32)val * 2); |
| 686 | | mips3com_update_cycle_counting(&mips3.core); |
| 1368 | m_core->cpr[0][idx] = val; |
| 1369 | m_core->count_zero_time = total_cycles() - ((UINT64)(UINT32)val * 2); |
| 1370 | mips3com_update_cycle_counting(); |
| 687 | 1371 | break; |
| 688 | 1372 | |
| 689 | 1373 | case COP0_Compare: |
| 690 | | mips3.core.compare_armed = 1; |
| 1374 | m_core->compare_armed = 1; |
| 691 | 1375 | CAUSE &= ~0x8000; |
| 692 | | mips3.core.cpr[0][idx] = val & 0xffffffff; |
| 693 | | mips3com_update_cycle_counting(&mips3.core); |
| 1376 | m_core->cpr[0][idx] = val & 0xffffffff; |
| 1377 | mips3com_update_cycle_counting(); |
| 694 | 1378 | break; |
| 695 | 1379 | |
| 696 | 1380 | case COP0_PRId: |
| 697 | 1381 | break; |
| 698 | 1382 | |
| 699 | 1383 | case COP0_Config: |
| 700 | | mips3.core.cpr[0][idx] = (mips3.core.cpr[0][idx] & ~7) | (val & 7); |
| 1384 | m_core->cpr[0][idx] = (m_core->cpr[0][idx] & ~7) | (val & 7); |
| 701 | 1385 | break; |
| 702 | 1386 | |
| 703 | 1387 | case COP0_EntryHi: |
| 704 | 1388 | /* if the ASID changes, remap */ |
| 705 | | if ((mips3.core.cpr[0][idx] ^ val) & 0xff) |
| 1389 | if ((m_core->cpr[0][idx] ^ val) & 0xff) |
| 706 | 1390 | { |
| 707 | | mips3.core.cpr[0][idx] = val; |
| 708 | | mips3com_asid_changed(&mips3.core); |
| 1391 | m_core->cpr[0][idx] = val; |
| 1392 | mips3com_asid_changed(); |
| 709 | 1393 | } |
| 710 | | mips3.core.cpr[0][idx] = val; |
| 1394 | m_core->cpr[0][idx] = val; |
| 711 | 1395 | break; |
| 712 | 1396 | |
| 713 | 1397 | default: |
| 714 | | mips3.core.cpr[0][idx] = val; |
| 1398 | m_core->cpr[0][idx] = val; |
| 715 | 1399 | break; |
| 716 | 1400 | } |
| 717 | 1401 | } |
| 718 | 1402 | |
| 719 | | INLINE UINT64 get_cop0_creg(int idx) |
| 1403 | inline UINT64 mips3_device::get_cop0_creg(int idx) |
| 720 | 1404 | { |
| 721 | | return mips3.core.ccr[0][idx]; |
| 1405 | return m_core->ccr[0][idx]; |
| 722 | 1406 | } |
| 723 | 1407 | |
| 724 | | INLINE void set_cop0_creg(int idx, UINT64 val) |
| 1408 | inline void mips3_device::set_cop0_creg(int idx, UINT64 val) |
| 725 | 1409 | { |
| 726 | | mips3.core.ccr[0][idx] = val; |
| 1410 | m_core->ccr[0][idx] = val; |
| 727 | 1411 | } |
| 728 | 1412 | |
| 729 | | INLINE void handle_cop0(UINT32 op) |
| 1413 | inline void mips3_device::handle_cop0(UINT32 op) |
| 730 | 1414 | { |
| 731 | 1415 | if ((SR & SR_KSU_MASK) != SR_KSU_KERNEL && !(SR & SR_COP0)) |
| 732 | 1416 | { |
| 733 | | mips3.badcop_value = 0; |
| 1417 | m_badcop_value = 0; |
| 734 | 1418 | generate_exception(EXCEPTION_BADCOP, 1); |
| 735 | 1419 | } |
| 736 | 1420 | |
| r30757 | r30758 | |
| 745 | 1429 | case 0x08: /* BC */ |
| 746 | 1430 | switch (RTREG) |
| 747 | 1431 | { |
| 748 | | case 0x00: /* BCzF */ if (!mips3.cf[0]) ADDPC(SIMMVAL); break; |
| 749 | | case 0x01: /* BCzF */ if (mips3.cf[0]) ADDPC(SIMMVAL); break; |
| 1432 | case 0x00: /* BCzF */ if (!m_cf[0]) ADDPC(SIMMVAL); break; |
| 1433 | case 0x01: /* BCzF */ if (m_cf[0]) ADDPC(SIMMVAL); break; |
| 750 | 1434 | case 0x02: /* BCzFL */ invalid_instruction(op); break; |
| 751 | 1435 | case 0x03: /* BCzTL */ invalid_instruction(op); break; |
| 752 | 1436 | default: invalid_instruction(op); break; |
| r30757 | r30758 | |
| 771 | 1455 | switch (op & 0x01ffffff) |
| 772 | 1456 | { |
| 773 | 1457 | case 0x01: /* TLBR */ |
| 774 | | mips3com_tlbr(&mips3.core); |
| 1458 | mips3com_tlbr(); |
| 775 | 1459 | break; |
| 776 | 1460 | |
| 777 | 1461 | case 0x02: /* TLBWI */ |
| 778 | | mips3com_tlbwi(&mips3.core); |
| 1462 | mips3com_tlbwi(); |
| 779 | 1463 | break; |
| 780 | 1464 | |
| 781 | 1465 | case 0x06: /* TLBWR */ |
| 782 | | mips3com_tlbwr(&mips3.core); |
| 1466 | mips3com_tlbwr(); |
| 783 | 1467 | break; |
| 784 | 1468 | |
| 785 | 1469 | case 0x08: /* TLBP */ |
| 786 | | mips3com_tlbp(&mips3.core); |
| 1470 | mips3com_tlbp(); |
| 787 | 1471 | break; |
| 788 | 1472 | |
| 789 | 1473 | case 0x10: /* RFE */ invalid_instruction(op); break; |
| 790 | | case 0x18: /* ERET */ logerror("ERET\n"); mips3.core.pc = mips3.core.cpr[0][COP0_EPC]; SR &= ~SR_EXL; check_irqs(); mips3.lld_value ^= 0xffffffff; mips3.ll_value ^= 0xffffffff; break; |
| 1474 | case 0x18: /* ERET */ logerror("ERET\n"); m_core->pc = m_core->cpr[0][COP0_EPC]; SR &= ~SR_EXL; check_irqs(); m_lld_value ^= 0xffffffff; m_ll_value ^= 0xffffffff; break; |
| 791 | 1475 | case 0x20: /* WAIT */ break; |
| 792 | 1476 | default: invalid_instruction(op); break; |
| 793 | 1477 | } |
| r30757 | r30758 | |
| 802 | 1486 | COP1 (FPU) EXECUTION HANDLING |
| 803 | 1487 | ***************************************************************************/ |
| 804 | 1488 | |
| 805 | | INLINE UINT32 get_cop1_reg32(int idx) |
| 1489 | inline UINT32 mips3_device::get_cop1_reg32(int idx) |
| 806 | 1490 | { |
| 807 | 1491 | if (IS_FR0) |
| 808 | | return ((UINT32 *)&mips3.core.cpr[1][0])[idx]; |
| 1492 | return ((UINT32 *)&m_core->cpr[1][0])[idx]; |
| 809 | 1493 | else |
| 810 | | return mips3.core.cpr[1][idx]; |
| 1494 | return m_core->cpr[1][idx]; |
| 811 | 1495 | } |
| 812 | 1496 | |
| 813 | | INLINE UINT64 get_cop1_reg64(int idx) |
| 1497 | inline UINT64 mips3_device::get_cop1_reg64(int idx) |
| 814 | 1498 | { |
| 815 | 1499 | if (IS_FR0) |
| 816 | | return ((UINT64 *)&mips3.core.cpr[1][0])[idx/2]; |
| 1500 | return ((UINT64 *)&m_core->cpr[1][0])[idx/2]; |
| 817 | 1501 | else |
| 818 | | return mips3.core.cpr[1][idx]; |
| 1502 | return m_core->cpr[1][idx]; |
| 819 | 1503 | } |
| 820 | 1504 | |
| 821 | | INLINE void set_cop1_reg32(int idx, UINT32 val) |
| 1505 | inline void mips3_device::set_cop1_reg32(int idx, UINT32 val) |
| 822 | 1506 | { |
| 823 | 1507 | if (IS_FR0) |
| 824 | | ((UINT32 *)&mips3.core.cpr[1][0])[idx] = val; |
| 1508 | ((UINT32 *)&m_core->cpr[1][0])[idx] = val; |
| 825 | 1509 | else |
| 826 | | mips3.core.cpr[1][idx] = val; |
| 1510 | m_core->cpr[1][idx] = val; |
| 827 | 1511 | } |
| 828 | 1512 | |
| 829 | | INLINE void set_cop1_reg64(int idx, UINT64 val) |
| 1513 | inline void mips3_device::set_cop1_reg64(int idx, UINT64 val) |
| 830 | 1514 | { |
| 831 | 1515 | if (IS_FR0) |
| 832 | | ((UINT64 *)&mips3.core.cpr[1][0])[idx/2] = val; |
| 1516 | ((UINT64 *)&m_core->cpr[1][0])[idx/2] = val; |
| 833 | 1517 | else |
| 834 | | mips3.core.cpr[1][idx] = val; |
| 1518 | m_core->cpr[1][idx] = val; |
| 835 | 1519 | } |
| 836 | 1520 | |
| 837 | | INLINE UINT64 get_cop1_creg(int idx) |
| 1521 | inline UINT64 mips3_device::get_cop1_creg(int idx) |
| 838 | 1522 | { |
| 839 | 1523 | if (idx == 31) |
| 840 | 1524 | { |
| 841 | | UINT32 result = mips3.core.ccr[1][31] & ~0xfe800000; |
| 1525 | UINT32 result = m_core->ccr[1][31] & ~0xfe800000; |
| 842 | 1526 | int i; |
| 843 | 1527 | |
| 844 | 1528 | for (i = 0; i < 8; i++) |
| 845 | | if (mips3.cf[1][i]) |
| 1529 | if (m_cf[1][i]) |
| 846 | 1530 | result |= 1 << fcc_shift[i]; |
| 847 | 1531 | return result; |
| 848 | 1532 | } |
| 849 | | return mips3.core.ccr[1][idx]; |
| 1533 | return m_core->ccr[1][idx]; |
| 850 | 1534 | } |
| 851 | 1535 | |
| 852 | | INLINE void set_cop1_creg(int idx, UINT64 val) |
| 1536 | inline void mips3_device::set_cop1_creg(int idx, UINT64 val) |
| 853 | 1537 | { |
| 854 | | mips3.core.ccr[1][idx] = val; |
| 1538 | m_core->ccr[1][idx] = val; |
| 855 | 1539 | if (idx == 31) |
| 856 | 1540 | { |
| 857 | 1541 | int i; |
| 858 | 1542 | |
| 859 | 1543 | for (i = 0; i < 8; i++) |
| 860 | | mips3.cf[1][i] = (val >> fcc_shift[i]) & 1; |
| 1544 | m_cf[1][i] = (val >> fcc_shift[i]) & 1; |
| 861 | 1545 | } |
| 862 | 1546 | } |
| 863 | 1547 | |
| 864 | | INLINE void handle_cop1_fr0(UINT32 op) |
| 1548 | inline void mips3_device::handle_cop1_fr0(UINT32 op) |
| 865 | 1549 | { |
| 866 | 1550 | double dtemp; |
| 867 | 1551 | |
| r30757 | r30758 | |
| 869 | 1553 | |
| 870 | 1554 | if (!(SR & SR_COP1)) |
| 871 | 1555 | { |
| 872 | | mips3.badcop_value = 1; |
| 1556 | m_badcop_value = 1; |
| 873 | 1557 | generate_exception(EXCEPTION_BADCOP, 1); |
| 874 | 1558 | } |
| 875 | 1559 | |
| r30757 | r30758 | |
| 886 | 1570 | { |
| 887 | 1571 | case 0x00: /* BCzF */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); break; |
| 888 | 1572 | case 0x01: /* BCzT */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); break; |
| 889 | | case 0x02: /* BCzFL */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 890 | | case 0x03: /* BCzTL */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 1573 | case 0x02: /* BCzFL */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 1574 | case 0x03: /* BCzTL */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 891 | 1575 | } |
| 892 | 1576 | break; |
| 893 | 1577 | default: |
| r30757 | r30758 | |
| 1220 | 1904 | } |
| 1221 | 1905 | |
| 1222 | 1906 | |
| 1223 | | INLINE void handle_cop1_fr1(UINT32 op) |
| 1907 | inline void mips3_device::handle_cop1_fr1(UINT32 op) |
| 1224 | 1908 | { |
| 1225 | 1909 | double dtemp; |
| 1226 | 1910 | |
| r30757 | r30758 | |
| 1228 | 1912 | |
| 1229 | 1913 | if (!(SR & SR_COP1)) |
| 1230 | 1914 | { |
| 1231 | | mips3.badcop_value = 1; |
| 1915 | m_badcop_value = 1; |
| 1232 | 1916 | generate_exception(EXCEPTION_BADCOP, 1); |
| 1233 | 1917 | } |
| 1234 | 1918 | |
| r30757 | r30758 | |
| 1245 | 1929 | { |
| 1246 | 1930 | case 0x00: /* BCzF */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); break; |
| 1247 | 1931 | case 0x01: /* BCzT */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); break; |
| 1248 | | case 0x02: /* BCzFL */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 1249 | | case 0x03: /* BCzTL */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 1932 | case 0x02: /* BCzFL */ if (!GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 1933 | case 0x03: /* BCzTL */ if (GET_FCC((op >> 18) & 7)) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 1250 | 1934 | } |
| 1251 | 1935 | break; |
| 1252 | 1936 | default: |
| r30757 | r30758 | |
| 1584 | 2268 | COP1X (FPU EXTRA) EXECUTION HANDLING |
| 1585 | 2269 | ***************************************************************************/ |
| 1586 | 2270 | |
| 1587 | | INLINE void handle_cop1x_fr0(UINT32 op) |
| 2271 | inline void mips3_device::handle_cop1x_fr0(UINT32 op) |
| 1588 | 2272 | { |
| 1589 | 2273 | UINT64 temp64; |
| 1590 | 2274 | UINT32 temp; |
| 1591 | 2275 | |
| 1592 | 2276 | if (!(SR & SR_COP1)) |
| 1593 | 2277 | { |
| 1594 | | mips3.badcop_value = 1; |
| 2278 | m_badcop_value = 1; |
| 1595 | 2279 | generate_exception(EXCEPTION_BADCOP, 1); |
| 1596 | 2280 | } |
| 1597 | 2281 | |
| r30757 | r30758 | |
| 1663 | 2347 | } |
| 1664 | 2348 | |
| 1665 | 2349 | |
| 1666 | | INLINE void handle_cop1x_fr1(UINT32 op) |
| 2350 | inline void mips3_device::handle_cop1x_fr1(UINT32 op) |
| 1667 | 2351 | { |
| 1668 | 2352 | UINT64 temp64; |
| 1669 | 2353 | UINT32 temp; |
| 1670 | 2354 | |
| 1671 | 2355 | if (!(SR & SR_COP1)) |
| 1672 | 2356 | { |
| 1673 | | mips3.badcop_value = 1; |
| 2357 | m_badcop_value = 1; |
| 1674 | 2358 | generate_exception(EXCEPTION_BADCOP, 1); |
| 1675 | 2359 | } |
| 1676 | 2360 | |
| r30757 | r30758 | |
| 1747 | 2431 | COP2 (CUSTOM) EXECUTION HANDLING |
| 1748 | 2432 | ***************************************************************************/ |
| 1749 | 2433 | |
| 1750 | | INLINE UINT64 get_cop2_reg(int idx) |
| 2434 | inline UINT64 mips3_device::get_cop2_reg(int idx) |
| 1751 | 2435 | { |
| 1752 | | return mips3.core.cpr[2][idx]; |
| 2436 | return m_core->cpr[2][idx]; |
| 1753 | 2437 | } |
| 1754 | 2438 | |
| 1755 | | INLINE void set_cop2_reg(int idx, UINT64 val) |
| 2439 | inline void mips3_device::set_cop2_reg(int idx, UINT64 val) |
| 1756 | 2440 | { |
| 1757 | | mips3.core.cpr[2][idx] = val; |
| 2441 | m_core->cpr[2][idx] = val; |
| 1758 | 2442 | } |
| 1759 | 2443 | |
| 1760 | | INLINE UINT64 get_cop2_creg(int idx) |
| 2444 | inline UINT64 mips3_device::get_cop2_creg(int idx) |
| 1761 | 2445 | { |
| 1762 | | return mips3.core.ccr[2][idx]; |
| 2446 | return m_core->ccr[2][idx]; |
| 1763 | 2447 | } |
| 1764 | 2448 | |
| 1765 | | INLINE void set_cop2_creg(int idx, UINT64 val) |
| 2449 | inline void mips3_device::set_cop2_creg(int idx, UINT64 val) |
| 1766 | 2450 | { |
| 1767 | | mips3.core.ccr[2][idx] = val; |
| 2451 | m_core->ccr[2][idx] = val; |
| 1768 | 2452 | } |
| 1769 | 2453 | |
| 1770 | | INLINE void handle_cop2(UINT32 op) |
| 2454 | inline void mips3_device::handle_cop2(UINT32 op) |
| 1771 | 2455 | { |
| 1772 | 2456 | if (!(SR & SR_COP2)) |
| 1773 | 2457 | { |
| 1774 | | mips3.badcop_value = 2; |
| 2458 | m_badcop_value = 2; |
| 1775 | 2459 | generate_exception(EXCEPTION_BADCOP, 1); |
| 1776 | 2460 | } |
| 1777 | 2461 | |
| r30757 | r30758 | |
| 1786 | 2470 | case 0x08: /* BC */ |
| 1787 | 2471 | switch (RTREG) |
| 1788 | 2472 | { |
| 1789 | | case 0x00: /* BCzF */ if (!mips3.cf[2]) ADDPC(SIMMVAL); break; |
| 1790 | | case 0x01: /* BCzF */ if (mips3.cf[2]) ADDPC(SIMMVAL); break; |
| 2473 | case 0x00: /* BCzF */ if (!m_cf[2]) ADDPC(SIMMVAL); break; |
| 2474 | case 0x01: /* BCzF */ if (m_cf[2]) ADDPC(SIMMVAL); break; |
| 1791 | 2475 | case 0x02: /* BCzFL */ invalid_instruction(op); break; |
| 1792 | 2476 | case 0x03: /* BCzTL */ invalid_instruction(op); break; |
| 1793 | 2477 | default: invalid_instruction(op); break; |
| r30757 | r30758 | |
| 1819 | 2503 | CORE EXECUTION LOOP |
| 1820 | 2504 | ***************************************************************************/ |
| 1821 | 2505 | |
| 1822 | | CPU_EXECUTE( mips3 ) |
| 2506 | void mips3_device::execute_run() |
| 1823 | 2507 | { |
| 2508 | if (m_isdrc) |
| 2509 | { |
| 2510 | int execute_result; |
| 2511 | |
| 2512 | /* reset the cache if dirty */ |
| 2513 | if (m_cache_dirty) |
| 2514 | code_flush_cache(); |
| 2515 | m_cache_dirty = FALSE; |
| 2516 | |
| 2517 | /* execute */ |
| 2518 | do |
| 2519 | { |
| 2520 | /* run as much as we can */ |
| 2521 | execute_result = m_drcuml->execute(*m_entry); |
| 2522 | |
| 2523 | /* if we need to recompile, do it */ |
| 2524 | if (execute_result == EXECUTE_MISSING_CODE) |
| 2525 | { |
| 2526 | code_compile_block(m_core->mode, m_core->pc); |
| 2527 | } |
| 2528 | else if (execute_result == EXECUTE_UNMAPPED_CODE) |
| 2529 | { |
| 2530 | fatalerror("Attempted to execute unmapped code at PC=%08X\n", m_core->pc); |
| 2531 | } |
| 2532 | else if (execute_result == EXECUTE_RESET_CACHE) |
| 2533 | { |
| 2534 | code_flush_cache(); |
| 2535 | } |
| 2536 | |
| 2537 | } while (execute_result != EXECUTE_OUT_OF_CYCLES); |
| 2538 | |
| 2539 | return; |
| 2540 | } |
| 2541 | |
| 1824 | 2542 | /* count cycles and interrupt cycles */ |
| 1825 | | mips3.core.icount -= mips3.interrupt_cycles; |
| 1826 | | mips3.interrupt_cycles = 0; |
| 2543 | m_core->icount -= m_interrupt_cycles; |
| 2544 | m_interrupt_cycles = 0; |
| 1827 | 2545 | |
| 1828 | 2546 | /* update timers & such */ |
| 1829 | | mips3com_update_cycle_counting(&mips3.core); |
| 2547 | mips3com_update_cycle_counting(); |
| 1830 | 2548 | |
| 1831 | 2549 | /* check for IRQs */ |
| 1832 | 2550 | check_irqs(); |
| r30757 | r30758 | |
| 1839 | 2557 | UINT32 temp; |
| 1840 | 2558 | |
| 1841 | 2559 | /* debugging */ |
| 1842 | | mips3.ppc = mips3.core.pc; |
| 1843 | | debugger_instruction_hook(device, mips3.core.pc); |
| 2560 | m_ppc = m_core->pc; |
| 2561 | debugger_instruction_hook(this, m_core->pc); |
| 1844 | 2562 | |
| 1845 | 2563 | /* instruction fetch */ |
| 1846 | | if(!RWORD(mips3.core.pc, &op)) |
| 2564 | if(!RWORD(m_core->pc, &op)) |
| 1847 | 2565 | { |
| 1848 | 2566 | continue; |
| 1849 | 2567 | } |
| 1850 | 2568 | |
| 1851 | 2569 | /* adjust for next PC */ |
| 1852 | | if (mips3.nextpc != ~0) |
| 2570 | if (m_nextpc != ~0) |
| 1853 | 2571 | { |
| 1854 | | mips3.core.pc = mips3.nextpc; |
| 1855 | | mips3.nextpc = ~0; |
| 2572 | m_core->pc = m_nextpc; |
| 2573 | m_nextpc = ~0; |
| 1856 | 2574 | } |
| 1857 | 2575 | else |
| 1858 | | mips3.core.pc += 4; |
| 2576 | m_core->pc += 4; |
| 1859 | 2577 | |
| 1860 | 2578 | /* parse the instruction */ |
| 1861 | 2579 | switch (op >> 26) |
| r30757 | r30758 | |
| 1888 | 2606 | temp64 = (INT64)(INT32)RSVAL32 * (INT64)(INT32)RTVAL32; |
| 1889 | 2607 | LOVAL64 = (INT32)temp64; |
| 1890 | 2608 | HIVAL64 = (INT32)(temp64 >> 32); |
| 1891 | | mips3.core.icount -= 3; |
| 2609 | m_core->icount -= 3; |
| 1892 | 2610 | break; |
| 1893 | 2611 | case 0x19: /* MULTU */ |
| 1894 | 2612 | temp64 = (UINT64)RSVAL32 * (UINT64)RTVAL32; |
| 1895 | 2613 | LOVAL64 = (INT32)temp64; |
| 1896 | 2614 | HIVAL64 = (INT32)(temp64 >> 32); |
| 1897 | | mips3.core.icount -= 3; |
| 2615 | m_core->icount -= 3; |
| 1898 | 2616 | break; |
| 1899 | 2617 | case 0x1a: /* DIV */ |
| 1900 | 2618 | if (RTVAL32) |
| r30757 | r30758 | |
| 1902 | 2620 | LOVAL64 = (INT32)((INT32)RSVAL32 / (INT32)RTVAL32); |
| 1903 | 2621 | HIVAL64 = (INT32)((INT32)RSVAL32 % (INT32)RTVAL32); |
| 1904 | 2622 | } |
| 1905 | | mips3.core.icount -= 35; |
| 2623 | m_core->icount -= 35; |
| 1906 | 2624 | break; |
| 1907 | 2625 | case 0x1b: /* DIVU */ |
| 1908 | 2626 | if (RTVAL32) |
| r30757 | r30758 | |
| 1910 | 2628 | LOVAL64 = (INT32)(RSVAL32 / RTVAL32); |
| 1911 | 2629 | HIVAL64 = (INT32)(RSVAL32 % RTVAL32); |
| 1912 | 2630 | } |
| 1913 | | mips3.core.icount -= 35; |
| 2631 | m_core->icount -= 35; |
| 1914 | 2632 | break; |
| 1915 | 2633 | case 0x1c: /* DMULT */ |
| 1916 | 2634 | temp64 = (INT64)RSVAL64 * (INT64)RTVAL64; |
| 1917 | 2635 | LOVAL64 = temp64; |
| 1918 | 2636 | HIVAL64 = (INT64)temp64 >> 63; |
| 1919 | | mips3.core.icount -= 7; |
| 2637 | m_core->icount -= 7; |
| 1920 | 2638 | break; |
| 1921 | 2639 | case 0x1d: /* DMULTU */ |
| 1922 | 2640 | temp64 = (UINT64)RSVAL64 * (UINT64)RTVAL64; |
| 1923 | 2641 | LOVAL64 = temp64; |
| 1924 | 2642 | HIVAL64 = 0; |
| 1925 | | mips3.core.icount -= 7; |
| 2643 | m_core->icount -= 7; |
| 1926 | 2644 | break; |
| 1927 | 2645 | case 0x1e: /* DDIV */ |
| 1928 | 2646 | if (RTVAL64) |
| r30757 | r30758 | |
| 1930 | 2648 | LOVAL64 = (INT64)RSVAL64 / (INT64)RTVAL64; |
| 1931 | 2649 | HIVAL64 = (INT64)RSVAL64 % (INT64)RTVAL64; |
| 1932 | 2650 | } |
| 1933 | | mips3.core.icount -= 67; |
| 2651 | m_core->icount -= 67; |
| 1934 | 2652 | break; |
| 1935 | 2653 | case 0x1f: /* DDIVU */ |
| 1936 | 2654 | if (RTVAL64) |
| r30757 | r30758 | |
| 1938 | 2656 | LOVAL64 = RSVAL64 / RTVAL64; |
| 1939 | 2657 | HIVAL64 = RSVAL64 % RTVAL64; |
| 1940 | 2658 | } |
| 1941 | | mips3.core.icount -= 67; |
| 2659 | m_core->icount -= 67; |
| 1942 | 2660 | break; |
| 1943 | 2661 | case 0x20: /* ADD */ |
| 1944 | 2662 | if (ENABLE_OVERFLOWS && RSVAL32 > ~RTVAL32) generate_exception(EXCEPTION_OVERFLOW, 1); |
| r30757 | r30758 | |
| 1987 | 2705 | { |
| 1988 | 2706 | case 0x00: /* BLTZ */ if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL); break; |
| 1989 | 2707 | case 0x01: /* BGEZ */ if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL); break; |
| 1990 | | case 0x02: /* BLTZL */ if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 1991 | | case 0x03: /* BGEZL */ if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 2708 | case 0x02: /* BLTZL */ if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 2709 | case 0x03: /* BGEZL */ if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 1992 | 2710 | case 0x08: /* TGEI */ if ((INT64)RSVAL64 >= SIMMVAL) generate_exception(EXCEPTION_TRAP, 1); break; |
| 1993 | 2711 | case 0x09: /* TGEIU */ if (RSVAL64 >= UIMMVAL) generate_exception(EXCEPTION_TRAP, 1); break; |
| 1994 | 2712 | case 0x0a: /* TLTI */ if ((INT64)RSVAL64 < SIMMVAL) generate_exception(EXCEPTION_TRAP, 1); break; |
| r30757 | r30758 | |
| 1997 | 2715 | case 0x0e: /* TNEI */ if (RSVAL64 != UIMMVAL) generate_exception(EXCEPTION_TRAP, 1); break; |
| 1998 | 2716 | case 0x10: /* BLTZAL */ if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31); break; |
| 1999 | 2717 | case 0x11: /* BGEZAL */ if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31); break; |
| 2000 | | case 0x12: /* BLTZALL */ if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31) else mips3.core.pc += 4; break; |
| 2001 | | case 0x13: /* BGEZALL */ if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31) else mips3.core.pc += 4; break; |
| 2718 | case 0x12: /* BLTZALL */ if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4; break; |
| 2719 | case 0x13: /* BGEZALL */ if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4; break; |
| 2002 | 2720 | default: /* ??? */ invalid_instruction(op); break; |
| 2003 | 2721 | } |
| 2004 | 2722 | break; |
| r30757 | r30758 | |
| 2024 | 2742 | case 0x11: /* COP1 */ if (IS_FR0) handle_cop1_fr0(op); else handle_cop1_fr1(op); break; |
| 2025 | 2743 | case 0x12: /* COP2 */ handle_cop2(op); break; |
| 2026 | 2744 | case 0x13: /* COP1X - R5000 */if (IS_FR0) handle_cop1x_fr0(op); else handle_cop1x_fr1(op); break; |
| 2027 | | case 0x14: /* BEQL */ if (RSVAL64 == RTVAL64) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 2028 | | case 0x15: /* BNEL */ if (RSVAL64 != RTVAL64) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 2029 | | case 0x16: /* BLEZL */ if ((INT64)RSVAL64 <= 0) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 2030 | | case 0x17: /* BGTZL */ if ((INT64)RSVAL64 > 0) ADDPC(SIMMVAL); else mips3.core.pc += 4; break; |
| 2745 | case 0x14: /* BEQL */ if (RSVAL64 == RTVAL64) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 2746 | case 0x15: /* BNEL */ if (RSVAL64 != RTVAL64) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 2747 | case 0x16: /* BLEZL */ if ((INT64)RSVAL64 <= 0) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 2748 | case 0x17: /* BGTZL */ if ((INT64)RSVAL64 > 0) ADDPC(SIMMVAL); else m_core->pc += 4; break; |
| 2031 | 2749 | case 0x18: /* DADDI */ |
| 2032 | 2750 | if (ENABLE_OVERFLOWS && (INT64)RSVAL64 > ~SIMMVAL) generate_exception(EXCEPTION_OVERFLOW, 1); |
| 2033 | 2751 | else if (RTREG) RTVAL64 = RSVAL64 + (INT64)SIMMVAL; |
| 2034 | 2752 | break; |
| 2035 | 2753 | case 0x19: /* DADDIU */ if (RTREG) RTVAL64 = RSVAL64 + (UINT64)SIMMVAL; break; |
| 2036 | | case 0x1a: /* LDL */ (*mips3.ldl)(op); break; |
| 2037 | | case 0x1b: /* LDR */ (*mips3.ldr)(op); break; |
| 2754 | case 0x1a: /* LDL */ (this->*m_ldl)(op); break; |
| 2755 | case 0x1b: /* LDR */ (this->*m_ldr)(op); break; |
| 2038 | 2756 | case 0x1c: /* IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364 */ |
| 2039 | 2757 | switch (op & 0x1f) |
| 2040 | 2758 | { |
| 2041 | 2759 | case 2: /* MUL */ |
| 2042 | 2760 | RDVAL64 = (INT32)((INT32)RSVAL32 * (INT32)RTVAL32); |
| 2043 | | mips3.core.icount -= 3; |
| 2761 | m_core->icount -= 3; |
| 2044 | 2762 | break; |
| 2045 | 2763 | default: invalid_instruction(op); |
| 2046 | 2764 | } |
| 2047 | 2765 | break; |
| 2048 | 2766 | case 0x20: /* LB */ if (RBYTE(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (INT8)temp; break; |
| 2049 | 2767 | case 0x21: /* LH */ if (RHALF(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (INT16)temp; break; |
| 2050 | | case 0x22: /* LWL */ (*mips3.lwl)(op); break; |
| 2768 | case 0x22: /* LWL */ (this->*m_lwl)(op); break; |
| 2051 | 2769 | case 0x23: /* LW */ if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (INT32)temp; break; |
| 2052 | 2770 | case 0x24: /* LBU */ if (RBYTE(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (UINT8)temp; break; |
| 2053 | 2771 | case 0x25: /* LHU */ if (RHALF(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (UINT16)temp; break; |
| 2054 | | case 0x26: /* LWR */ (*mips3.lwr)(op); break; |
| 2772 | case 0x26: /* LWR */ (this->*m_lwr)(op); break; |
| 2055 | 2773 | case 0x27: /* LWU */ if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (UINT32)temp; break; |
| 2056 | 2774 | case 0x28: /* SB */ WBYTE(SIMMVAL+RSVAL32, RTVAL32); break; |
| 2057 | 2775 | case 0x29: /* SH */ WHALF(SIMMVAL+RSVAL32, RTVAL32); break; |
| 2058 | | case 0x2a: /* SWL */ (*mips3.swl)(op); break; |
| 2776 | case 0x2a: /* SWL */ (this->*m_swl)(op); break; |
| 2059 | 2777 | case 0x2b: /* SW */ WWORD(SIMMVAL+RSVAL32, RTVAL32); break; |
| 2060 | | case 0x2c: /* SDL */ (*mips3.sdl)(op); break; |
| 2061 | | case 0x2d: /* SDR */ (*mips3.sdr)(op); break; |
| 2062 | | case 0x2e: /* SWR */ (*mips3.swr)(op); break; |
| 2778 | case 0x2c: /* SDL */ (this->*m_sdl)(op); break; |
| 2779 | case 0x2d: /* SDR */ (this->*m_sdr)(op); break; |
| 2780 | case 0x2e: /* SWR */ (this->*m_swr)(op); break; |
| 2063 | 2781 | case 0x2f: /* CACHE */ /* effective no-op */ break; |
| 2064 | | case 0x30: /* LL */ if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (UINT32)temp; mips3.ll_value = RTVAL32; break; |
| 2782 | case 0x30: /* LL */ if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG) RTVAL64 = (UINT32)temp; m_ll_value = RTVAL32; break; |
| 2065 | 2783 | case 0x31: /* LWC1 */ if (RWORD(SIMMVAL+RSVAL32, &temp)) set_cop1_reg32(RTREG, temp); break; |
| 2066 | 2784 | case 0x32: /* LWC2 */ if (RWORD(SIMMVAL+RSVAL32, &temp)) set_cop2_reg(RTREG, temp); break; |
| 2067 | 2785 | case 0x33: /* PREF */ /* effective no-op */ break; |
| 2068 | | case 0x34: /* LLD */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG) RTVAL64 = temp64; mips3.lld_value = temp64; break; |
| 2786 | case 0x34: /* LLD */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG) RTVAL64 = temp64; m_lld_value = temp64; break; |
| 2069 | 2787 | case 0x35: /* LDC1 */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64)) set_cop1_reg64(RTREG, temp64); break; |
| 2070 | 2788 | case 0x36: /* LDC2 */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64)) set_cop2_reg(RTREG, temp64); break; |
| 2071 | 2789 | case 0x37: /* LD */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG) RTVAL64 = temp64; break; |
| 2072 | 2790 | case 0x38: /* SC */ if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG) |
| 2073 | 2791 | { |
| 2074 | | if (temp == mips3.ll_value) |
| 2792 | if (temp == m_ll_value) |
| 2075 | 2793 | { |
| 2076 | 2794 | WWORD(SIMMVAL+RSVAL32, RTVAL32); |
| 2077 | 2795 | RTVAL64 = (UINT32)1; |
| r30757 | r30758 | |
| 2087 | 2805 | case 0x3b: /* SWC3 */ invalid_instruction(op); break; |
| 2088 | 2806 | case 0x3c: /* SCD */ if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG) |
| 2089 | 2807 | { |
| 2090 | | if (temp64 == mips3.lld_value) |
| 2808 | if (temp64 == m_lld_value) |
| 2091 | 2809 | { |
| 2092 | 2810 | WDOUBLE(SIMMVAL+RSVAL32, RTVAL64); |
| 2093 | 2811 | RTVAL64 = 1; |
| r30757 | r30758 | |
| 2103 | 2821 | case 0x3f: /* SD */ WDOUBLE(SIMMVAL+RSVAL32, RTVAL64); break; |
| 2104 | 2822 | default: /* ??? */ invalid_instruction(op); break; |
| 2105 | 2823 | } |
| 2106 | | mips3.core.icount--; |
| 2824 | m_core->icount--; |
| 2107 | 2825 | |
| 2108 | | } while (mips3.core.icount > 0 || mips3.nextpc != ~0); |
| 2826 | } while (m_core->icount > 0 || m_nextpc != ~0); |
| 2109 | 2827 | |
| 2110 | | mips3.core.icount -= mips3.interrupt_cycles; |
| 2111 | | mips3.interrupt_cycles = 0; |
| 2828 | m_core->icount -= m_interrupt_cycles; |
| 2829 | m_interrupt_cycles = 0; |
| 2112 | 2830 | } |
| 2113 | 2831 | |
| 2114 | 2832 | |
| r30757 | r30758 | |
| 2117 | 2835 | COMPLEX OPCODE IMPLEMENTATIONS |
| 2118 | 2836 | ***************************************************************************/ |
| 2119 | 2837 | |
| 2120 | | static void lwl_be(UINT32 op) |
| 2838 | void mips3_device::lwl_be(UINT32 op) |
| 2121 | 2839 | { |
| 2122 | 2840 | offs_t offs = SIMMVAL + RSVAL32; |
| 2123 | 2841 | int shift = 8 * (offs & 3); |
| r30757 | r30758 | |
| 2128 | 2846 | RTVAL64 = (INT32)((RTVAL32 & ~mask) | (temp << shift)); |
| 2129 | 2847 | } |
| 2130 | 2848 | |
| 2131 | | static void lwr_be(UINT32 op) |
| 2849 | void mips3_device::lwr_be(UINT32 op) |
| 2132 | 2850 | { |
| 2133 | 2851 | offs_t offs = SIMMVAL + RSVAL32; |
| 2134 | 2852 | int shift = 8 * (~offs & 3); |
| r30757 | r30758 | |
| 2139 | 2857 | RTVAL64 = (INT32)((RTVAL32 & ~mask) | (temp >> shift)); |
| 2140 | 2858 | } |
| 2141 | 2859 | |
| 2142 | | static void ldl_be(UINT32 op) |
| 2860 | void mips3_device::ldl_be(UINT32 op) |
| 2143 | 2861 | { |
| 2144 | 2862 | offs_t offs = SIMMVAL + RSVAL32; |
| 2145 | 2863 | int shift = 8 * (offs & 7); |
| r30757 | r30758 | |
| 2150 | 2868 | RTVAL64 = (RTVAL64 & ~mask) | (temp << shift); |
| 2151 | 2869 | } |
| 2152 | 2870 | |
| 2153 | | static void ldr_be(UINT32 op) |
| 2871 | void mips3_device::ldr_be(UINT32 op) |
| 2154 | 2872 | { |
| 2155 | 2873 | offs_t offs = SIMMVAL + RSVAL32; |
| 2156 | 2874 | int shift = 8 * (~offs & 7); |
| r30757 | r30758 | |
| 2161 | 2879 | RTVAL64 = (RTVAL64 & ~mask) | (temp >> shift); |
| 2162 | 2880 | } |
| 2163 | 2881 | |
| 2164 | | static void swl_be(UINT32 op) |
| 2882 | void mips3_device::swl_be(UINT32 op) |
| 2165 | 2883 | { |
| 2166 | 2884 | offs_t offs = SIMMVAL + RSVAL32; |
| 2167 | 2885 | int shift = 8 * (offs & 3); |
| r30757 | r30758 | |
| 2169 | 2887 | WWORD_MASKED(offs & ~3, RTVAL32 >> shift, mask); |
| 2170 | 2888 | } |
| 2171 | 2889 | |
| 2172 | | static void swr_be(UINT32 op) |
| 2890 | void mips3_device::swr_be(UINT32 op) |
| 2173 | 2891 | { |
| 2174 | 2892 | offs_t offs = SIMMVAL + RSVAL32; |
| 2175 | 2893 | int shift = 8 * (~offs & 3); |
| r30757 | r30758 | |
| 2177 | 2895 | WWORD_MASKED(offs & ~3, RTVAL32 << shift, mask); |
| 2178 | 2896 | } |
| 2179 | 2897 | |
| 2180 | | static void sdl_be(UINT32 op) |
| 2898 | void mips3_device::sdl_be(UINT32 op) |
| 2181 | 2899 | { |
| 2182 | 2900 | offs_t offs = SIMMVAL + RSVAL32; |
| 2183 | 2901 | int shift = 8 * (offs & 7); |
| r30757 | r30758 | |
| 2185 | 2903 | WDOUBLE_MASKED(offs & ~7, RTVAL64 >> shift, mask); |
| 2186 | 2904 | } |
| 2187 | 2905 | |
| 2188 | | static void sdr_be(UINT32 op) |
| 2906 | void mips3_device::sdr_be(UINT32 op) |
| 2189 | 2907 | { |
| 2190 | 2908 | offs_t offs = SIMMVAL + RSVAL32; |
| 2191 | 2909 | int shift = 8 * (~offs & 7); |
| r30757 | r30758 | |
| 2195 | 2913 | |
| 2196 | 2914 | |
| 2197 | 2915 | |
| 2198 | | static void lwl_le(UINT32 op) |
| 2916 | void mips3_device::lwl_le(UINT32 op) |
| 2199 | 2917 | { |
| 2200 | 2918 | offs_t offs = SIMMVAL + RSVAL32; |
| 2201 | 2919 | int shift = 8 * (~offs & 3); |
| r30757 | r30758 | |
| 2206 | 2924 | RTVAL64 = (INT32)((RTVAL32 & ~mask) | (temp << shift)); |
| 2207 | 2925 | } |
| 2208 | 2926 | |
| 2209 | | static void lwr_le(UINT32 op) |
| 2927 | void mips3_device::lwr_le(UINT32 op) |
| 2210 | 2928 | { |
| 2211 | 2929 | offs_t offs = SIMMVAL + RSVAL32; |
| 2212 | 2930 | int shift = 8 * (offs & 3); |
| r30757 | r30758 | |
| 2217 | 2935 | RTVAL64 = (INT32)((RTVAL32 & ~mask) | (temp >> shift)); |
| 2218 | 2936 | } |
| 2219 | 2937 | |
| 2220 | | static void ldl_le(UINT32 op) |
| 2938 | void mips3_device::ldl_le(UINT32 op) |
| 2221 | 2939 | { |
| 2222 | 2940 | offs_t offs = SIMMVAL + RSVAL32; |
| 2223 | 2941 | int shift = 8 * (~offs & 7); |
| r30757 | r30758 | |
| 2228 | 2946 | RTVAL64 = (RTVAL64 & ~mask) | (temp << shift); |
| 2229 | 2947 | } |
| 2230 | 2948 | |
| 2231 | | static void ldr_le(UINT32 op) |
| 2949 | void mips3_device::ldr_le(UINT32 op) |
| 2232 | 2950 | { |
| 2233 | 2951 | offs_t offs = SIMMVAL + RSVAL32; |
| 2234 | 2952 | int shift = 8 * (offs & 7); |
| r30757 | r30758 | |
| 2239 | 2957 | RTVAL64 = (RTVAL64 & ~mask) | (temp >> shift); |
| 2240 | 2958 | } |
| 2241 | 2959 | |
| 2242 | | static void swl_le(UINT32 op) |
| 2960 | void mips3_device::swl_le(UINT32 op) |
| 2243 | 2961 | { |
| 2244 | 2962 | offs_t offs = SIMMVAL + RSVAL32; |
| 2245 | 2963 | int shift = 8 * (~offs & 3); |
| r30757 | r30758 | |
| 2247 | 2965 | WWORD_MASKED(offs & ~3, RTVAL32 >> shift, mask); |
| 2248 | 2966 | } |
| 2249 | 2967 | |
| 2250 | | static void swr_le(UINT32 op) |
| 2968 | void mips3_device::swr_le(UINT32 op) |
| 2251 | 2969 | { |
| 2252 | 2970 | offs_t offs = SIMMVAL + RSVAL32; |
| 2253 | 2971 | int shift = 8 * (offs & 3); |
| r30757 | r30758 | |
| 2255 | 2973 | WWORD_MASKED(offs & ~3, RTVAL32 << shift, mask); |
| 2256 | 2974 | } |
| 2257 | 2975 | |
| 2258 | | static void sdl_le(UINT32 op) |
| 2976 | void mips3_device::sdl_le(UINT32 op) |
| 2259 | 2977 | { |
| 2260 | 2978 | offs_t offs = SIMMVAL + RSVAL32; |
| 2261 | 2979 | int shift = 8 * (~offs & 7); |
| r30757 | r30758 | |
| 2263 | 2981 | WDOUBLE_MASKED(offs & ~7, RTVAL64 >> shift, mask); |
| 2264 | 2982 | } |
| 2265 | 2983 | |
| 2266 | | static void sdr_le(UINT32 op) |
| 2984 | void mips3_device::sdr_le(UINT32 op) |
| 2267 | 2985 | { |
| 2268 | 2986 | offs_t offs = SIMMVAL + RSVAL32; |
| 2269 | 2987 | int shift = 8 * (offs & 7); |
| r30757 | r30758 | |
| 2271 | 2989 | WDOUBLE_MASKED(offs & ~7, RTVAL64 << shift, mask); |
| 2272 | 2990 | } |
| 2273 | 2991 | |
| 2274 | | |
| 2275 | | |
| 2276 | | /*************************************************************************** |
| 2277 | | GENERIC GET/SET INFO |
| 2278 | | ***************************************************************************/ |
| 2279 | | |
| 2280 | | static CPU_SET_INFO( mips3 ) |
| 2281 | | { |
| 2282 | | /* everything is handled generically here */ |
| 2283 | | mips3com_set_info(&mips3.core, state, info); |
| 2284 | | } |
| 2285 | | |
| 2286 | | |
| 2287 | | static CPU_GET_INFO( mips3 ) |
| 2288 | | { |
| 2289 | | switch (state) |
| 2290 | | { |
| 2291 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2292 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(mips3); break; |
| 2293 | | case CPUINFO_INT_PREVIOUSPC: info->i = mips3.ppc; break; |
| 2294 | | |
| 2295 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2296 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(mips3); break; |
| 2297 | | case CPUINFO_FCT_INIT: /* provided per-CPU */ break; |
| 2298 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(mips3); break; |
| 2299 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(mips3); break; |
| 2300 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(mips3); break; |
| 2301 | | case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(mips3); break; |
| 2302 | | |
| 2303 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2304 | | case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 2305 | | |
| 2306 | | /* --- everything else is handled generically --- */ |
| 2307 | | default: mips3com_get_info(&mips3.core, state, info); break; |
| 2308 | | } |
| 2309 | | } |
| 2310 | | |
| 2311 | | |
| 2312 | | |
| 2313 | | /*************************************************************************** |
| 2314 | | NEC VR4300 VARIANTS |
| 2315 | | ***************************************************************************/ |
| 2316 | | |
| 2317 | | // NEC VR4300 series is MIPS III with 32-bit address bus and slightly custom COP0/TLB |
| 2318 | | static CPU_INIT( vr4300be ) |
| 2319 | | { |
| 2320 | | mips3com_init(&mips3.core, MIPS3_TYPE_VR4300, TRUE, device, irqcallback); |
| 2321 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2322 | | } |
| 2323 | | |
| 2324 | | static CPU_INIT( vr4300le ) |
| 2325 | | { |
| 2326 | | mips3com_init(&mips3.core, MIPS3_TYPE_VR4300, FALSE, device, irqcallback); |
| 2327 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2328 | | } |
| 2329 | | |
| 2330 | | CPU_GET_INFO( vr4300be_int ) |
| 2331 | | { |
| 2332 | | switch (state) |
| 2333 | | { |
| 2334 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2335 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2336 | | |
| 2337 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2338 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300be); break; |
| 2339 | | |
| 2340 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2341 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4300 (big)"); break; |
| 2342 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4300be"); break; |
| 2343 | | |
| 2344 | | /* --- everything else is handled generically --- */ |
| 2345 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2346 | | } |
| 2347 | | } |
| 2348 | | |
| 2349 | | CPU_GET_INFO( vr4300le_int ) |
| 2350 | | { |
| 2351 | | switch (state) |
| 2352 | | { |
| 2353 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2354 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2355 | | |
| 2356 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2357 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300le); break; |
| 2358 | | |
| 2359 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2360 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4300 (little)"); break; |
| 2361 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4300le"); break; |
| 2362 | | |
| 2363 | | /* --- everything else is handled generically --- */ |
| 2364 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2365 | | } |
| 2366 | | } |
| 2367 | | |
| 2368 | | // VR4310 = VR4300 with different speed bin |
| 2369 | | CPU_GET_INFO( vr4310be_int ) |
| 2370 | | { |
| 2371 | | switch (state) |
| 2372 | | { |
| 2373 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2374 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2375 | | |
| 2376 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2377 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300be); break; |
| 2378 | | |
| 2379 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2380 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4310 (big)"); break; |
| 2381 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4310be"); break; |
| 2382 | | |
| 2383 | | /* --- everything else is handled generically --- */ |
| 2384 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2385 | | } |
| 2386 | | } |
| 2387 | | |
| 2388 | | CPU_GET_INFO( vr4310le_int ) |
| 2389 | | { |
| 2390 | | switch (state) |
| 2391 | | { |
| 2392 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2393 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2394 | | |
| 2395 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2396 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300le); break; |
| 2397 | | |
| 2398 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2399 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4310 (little)"); break; |
| 2400 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4310le"); break; |
| 2401 | | |
| 2402 | | /* --- everything else is handled generically --- */ |
| 2403 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2404 | | } |
| 2405 | | } |
| 2406 | | |
| 2407 | | |
| 2408 | | /*************************************************************************** |
| 2409 | | R4600 VARIANTS |
| 2410 | | ***************************************************************************/ |
| 2411 | | |
| 2412 | | static CPU_INIT( r4600be ) |
| 2413 | | { |
| 2414 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4600, TRUE, device, irqcallback); |
| 2415 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2416 | | } |
| 2417 | | |
| 2418 | | static CPU_INIT( r4600le ) |
| 2419 | | { |
| 2420 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4600, FALSE, device, irqcallback); |
| 2421 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2422 | | } |
| 2423 | | |
| 2424 | | CPU_GET_INFO( r4600be_int ) |
| 2425 | | { |
| 2426 | | switch (state) |
| 2427 | | { |
| 2428 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2429 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2430 | | |
| 2431 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2432 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4600be); break; |
| 2433 | | |
| 2434 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2435 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4600 (big)"); break; |
| 2436 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4600be"); break; |
| 2437 | | |
| 2438 | | /* --- everything else is handled generically --- */ |
| 2439 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2440 | | } |
| 2441 | | } |
| 2442 | | |
| 2443 | | CPU_GET_INFO( r4600le_int ) |
| 2444 | | { |
| 2445 | | switch (state) |
| 2446 | | { |
| 2447 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2448 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2449 | | |
| 2450 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2451 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4600le); break; |
| 2452 | | |
| 2453 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2454 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4600 (little)"); break; |
| 2455 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4600le"); break; |
| 2456 | | |
| 2457 | | /* --- everything else is handled generically --- */ |
| 2458 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2459 | | } |
| 2460 | | } |
| 2461 | | |
| 2462 | | |
| 2463 | | |
| 2464 | | /*************************************************************************** |
| 2465 | | R4650 VARIANTS |
| 2466 | | ***************************************************************************/ |
| 2467 | | |
| 2468 | | static CPU_INIT( r4650be ) |
| 2469 | | { |
| 2470 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4650, TRUE, device, irqcallback); |
| 2471 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2472 | | } |
| 2473 | | |
| 2474 | | static CPU_INIT( r4650le ) |
| 2475 | | { |
| 2476 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4650, FALSE, device, irqcallback); |
| 2477 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2478 | | } |
| 2479 | | |
| 2480 | | CPU_GET_INFO( r4650be_int ) |
| 2481 | | { |
| 2482 | | switch (state) |
| 2483 | | { |
| 2484 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2485 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2486 | | |
| 2487 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2488 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4650be); break; |
| 2489 | | |
| 2490 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2491 | | case CPUINFO_STR_NAME: strcpy(info->s, "IDT R4650 (big)"); break; |
| 2492 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4650be"); break; |
| 2493 | | |
| 2494 | | /* --- everything else is handled generically --- */ |
| 2495 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2496 | | } |
| 2497 | | } |
| 2498 | | |
| 2499 | | CPU_GET_INFO( r4650le_int ) |
| 2500 | | { |
| 2501 | | switch (state) |
| 2502 | | { |
| 2503 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2504 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2505 | | |
| 2506 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2507 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4650le); break; |
| 2508 | | |
| 2509 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2510 | | case CPUINFO_STR_NAME: strcpy(info->s, "IDT R4650 (little)"); break; |
| 2511 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4650le"); break; |
| 2512 | | |
| 2513 | | /* --- everything else is handled generically --- */ |
| 2514 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2515 | | } |
| 2516 | | } |
| 2517 | | |
| 2518 | | |
| 2519 | | |
| 2520 | | /*************************************************************************** |
| 2521 | | R4700 VARIANTS |
| 2522 | | ***************************************************************************/ |
| 2523 | | |
| 2524 | | static CPU_INIT( r4700be ) |
| 2525 | | { |
| 2526 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4700, TRUE, device, irqcallback); |
| 2527 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2528 | | } |
| 2529 | | |
| 2530 | | static CPU_INIT( r4700le ) |
| 2531 | | { |
| 2532 | | mips3com_init(&mips3.core, MIPS3_TYPE_R4700, FALSE, device, irqcallback); |
| 2533 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2534 | | } |
| 2535 | | |
| 2536 | | CPU_GET_INFO( r4700be_int ) |
| 2537 | | { |
| 2538 | | switch (state) |
| 2539 | | { |
| 2540 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2541 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2542 | | |
| 2543 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2544 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4700be); break; |
| 2545 | | |
| 2546 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2547 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4700 (big)"); break; |
| 2548 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4700be"); break; |
| 2549 | | |
| 2550 | | /* --- everything else is handled generically --- */ |
| 2551 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2552 | | } |
| 2553 | | } |
| 2554 | | |
| 2555 | | |
| 2556 | | CPU_GET_INFO( r4700le_int ) |
| 2557 | | { |
| 2558 | | switch (state) |
| 2559 | | { |
| 2560 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2561 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2562 | | |
| 2563 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2564 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4700le); break; |
| 2565 | | |
| 2566 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2567 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4700 (little)"); break; |
| 2568 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4700le"); break; |
| 2569 | | |
| 2570 | | /* --- everything else is handled generically --- */ |
| 2571 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2572 | | } |
| 2573 | | } |
| 2574 | | |
| 2575 | | |
| 2576 | | |
| 2577 | | /*************************************************************************** |
| 2578 | | R5000 VARIANTS |
| 2579 | | ***************************************************************************/ |
| 2580 | | |
| 2581 | | static CPU_INIT( r5000be ) |
| 2582 | | { |
| 2583 | | mips3com_init(&mips3.core, MIPS3_TYPE_R5000, TRUE, device, irqcallback); |
| 2584 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2585 | | } |
| 2586 | | |
| 2587 | | static CPU_INIT( r5000le ) |
| 2588 | | { |
| 2589 | | mips3com_init(&mips3.core, MIPS3_TYPE_R5000, FALSE, device, irqcallback); |
| 2590 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2591 | | } |
| 2592 | | |
| 2593 | | CPU_GET_INFO( r5000be_int ) |
| 2594 | | { |
| 2595 | | switch (state) |
| 2596 | | { |
| 2597 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2598 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2599 | | |
| 2600 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2601 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r5000be); break; |
| 2602 | | |
| 2603 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2604 | | case CPUINFO_STR_NAME: strcpy(info->s, "R5000 (big)"); break; |
| 2605 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r5000be"); break; |
| 2606 | | |
| 2607 | | /* --- everything else is handled generically --- */ |
| 2608 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2609 | | } |
| 2610 | | } |
| 2611 | | |
| 2612 | | CPU_GET_INFO( r5000le_int ) |
| 2613 | | { |
| 2614 | | switch (state) |
| 2615 | | { |
| 2616 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2617 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2618 | | |
| 2619 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2620 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r5000le); break; |
| 2621 | | |
| 2622 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2623 | | case CPUINFO_STR_NAME: strcpy(info->s, "R5000 (little)"); break; |
| 2624 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r5000le"); break; |
| 2625 | | |
| 2626 | | /* --- everything else is handled generically --- */ |
| 2627 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2628 | | } |
| 2629 | | } |
| 2630 | | |
| 2631 | | |
| 2632 | | |
| 2633 | | /*************************************************************************** |
| 2634 | | QED5271 VARIANTS |
| 2635 | | ***************************************************************************/ |
| 2636 | | |
| 2637 | | static CPU_INIT( qed5271be ) |
| 2638 | | { |
| 2639 | | mips3com_init(&mips3.core, MIPS3_TYPE_QED5271, TRUE, device, irqcallback); |
| 2640 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2641 | | } |
| 2642 | | |
| 2643 | | static CPU_INIT( qed5271le ) |
| 2644 | | { |
| 2645 | | mips3com_init(&mips3.core, MIPS3_TYPE_QED5271, FALSE, device, irqcallback); |
| 2646 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2647 | | } |
| 2648 | | |
| 2649 | | CPU_GET_INFO( qed5271be_int ) |
| 2650 | | { |
| 2651 | | switch (state) |
| 2652 | | { |
| 2653 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2654 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2655 | | |
| 2656 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2657 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(qed5271be); break; |
| 2658 | | |
| 2659 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2660 | | case CPUINFO_STR_NAME: strcpy(info->s, "QED5271 (big)"); break; |
| 2661 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "qed5271be"); break; |
| 2662 | | |
| 2663 | | /* --- everything else is handled generically --- */ |
| 2664 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2665 | | } |
| 2666 | | } |
| 2667 | | |
| 2668 | | CPU_GET_INFO( qed5271le_int ) |
| 2669 | | { |
| 2670 | | switch (state) |
| 2671 | | { |
| 2672 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2673 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2674 | | |
| 2675 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2676 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(qed5271le); break; |
| 2677 | | |
| 2678 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2679 | | case CPUINFO_STR_NAME: strcpy(info->s, "QED5271 (little)"); break; |
| 2680 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "qed5271le"); break; |
| 2681 | | |
| 2682 | | /* --- everything else is handled generically --- */ |
| 2683 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2684 | | } |
| 2685 | | } |
| 2686 | | |
| 2687 | | |
| 2688 | | |
| 2689 | | /*************************************************************************** |
| 2690 | | RM7000 VARIANTS |
| 2691 | | ***************************************************************************/ |
| 2692 | | |
| 2693 | | static CPU_INIT( rm7000be ) |
| 2694 | | { |
| 2695 | | mips3com_init(&mips3.core, MIPS3_TYPE_RM7000, TRUE, device, irqcallback); |
| 2696 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2697 | | } |
| 2698 | | |
| 2699 | | static CPU_INIT( rm7000le ) |
| 2700 | | { |
| 2701 | | mips3com_init(&mips3.core, MIPS3_TYPE_RM7000, FALSE, device, irqcallback); |
| 2702 | | mips3.tlb_table = vtlb_table(mips3.core.vtlb); |
| 2703 | | } |
| 2704 | | |
| 2705 | | CPU_GET_INFO( rm7000be_int ) |
| 2706 | | { |
| 2707 | | switch (state) |
| 2708 | | { |
| 2709 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2710 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 2711 | | |
| 2712 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2713 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(rm7000be); break; |
| 2714 | | |
| 2715 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2716 | | case CPUINFO_STR_NAME: strcpy(info->s, "RM7000 (big)"); break; |
| 2717 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "rm7000be"); break; |
| 2718 | | |
| 2719 | | /* --- everything else is handled generically --- */ |
| 2720 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2721 | | } |
| 2722 | | } |
| 2723 | | |
| 2724 | | CPU_GET_INFO( rm7000le_int ) |
| 2725 | | { |
| 2726 | | switch (state) |
| 2727 | | { |
| 2728 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2729 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 2730 | | |
| 2731 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2732 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(rm7000le); break; |
| 2733 | | |
| 2734 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2735 | | case CPUINFO_STR_NAME: strcpy(info->s, "RM7000 (little)"); break; |
| 2736 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "rm7000le"); break; |
| 2737 | | |
| 2738 | | /* --- everything else is handled generically --- */ |
| 2739 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 2740 | | } |
| 2741 | | } |
| 2742 | | |
| 2743 | | DEFINE_LEGACY_CPU_DEVICE(VR4300BE_INT, vr4300be_int); |
| 2744 | | DEFINE_LEGACY_CPU_DEVICE(VR4300LE_INT, vr4300le_int); |
| 2745 | | DEFINE_LEGACY_CPU_DEVICE(VR4310BE_INT, vr4310be_int); |
| 2746 | | DEFINE_LEGACY_CPU_DEVICE(VR4310LE_INT, vr4310le_int); |
| 2747 | | |
| 2748 | | DEFINE_LEGACY_CPU_DEVICE(R4600BE_INT, r4600be_int); |
| 2749 | | DEFINE_LEGACY_CPU_DEVICE(R4600LE_INT, r4600le_int); |
| 2750 | | |
| 2751 | | DEFINE_LEGACY_CPU_DEVICE(R4650BE_INT, r4650be_int); |
| 2752 | | DEFINE_LEGACY_CPU_DEVICE(R4650LE_INT, r4650le_int); |
| 2753 | | |
| 2754 | | DEFINE_LEGACY_CPU_DEVICE(R4700BE_INT, r4700be_int); |
| 2755 | | DEFINE_LEGACY_CPU_DEVICE(R4700LE_INT, r4700le_int); |
| 2756 | | |
| 2757 | | DEFINE_LEGACY_CPU_DEVICE(R5000BE_INT, r5000be_int); |
| 2758 | | DEFINE_LEGACY_CPU_DEVICE(R5000LE_INT, r5000le_int); |
| 2759 | | |
| 2760 | | DEFINE_LEGACY_CPU_DEVICE(QED5271BE_INT, qed5271be_int); |
| 2761 | | DEFINE_LEGACY_CPU_DEVICE(QED5271LE_INT, qed5271le_int); |
| 2762 | | |
| 2763 | | DEFINE_LEGACY_CPU_DEVICE(RM7000BE_INT, rm7000be_int); |
| 2764 | | DEFINE_LEGACY_CPU_DEVICE(RM7000LE_INT, rm7000le_int); |
| 2765 | | |
| 2766 | | const device_type VR4300BE = &legacy_device_creator_drc<vr4300be_int_device, vr4300be_drc_device>; |
| 2767 | | const device_type VR4300LE = &legacy_device_creator_drc<vr4300le_int_device, vr4300le_drc_device>; |
| 2768 | | const device_type VR4310BE = &legacy_device_creator_drc<vr4310be_int_device, vr4310be_drc_device>; |
| 2769 | | const device_type VR4310LE = &legacy_device_creator_drc<vr4310le_int_device, vr4310le_drc_device>; |
| 2770 | | const device_type R4600BE = &legacy_device_creator_drc<r4600be_int_device, r4600be_drc_device>; |
| 2771 | | const device_type R4600LE = &legacy_device_creator_drc<r4600le_int_device, r4600le_drc_device>; |
| 2772 | | const device_type R4650BE = &legacy_device_creator_drc<r4650be_int_device, r4650be_drc_device>; |
| 2773 | | const device_type R4650LE = &legacy_device_creator_drc<r4650le_int_device, r4650le_drc_device>; |
| 2774 | | const device_type R4700BE = &legacy_device_creator_drc<r4700be_int_device, r4700be_drc_device>; |
| 2775 | | const device_type R4700LE = &legacy_device_creator_drc<r4700le_int_device, r4700le_drc_device>; |
| 2776 | | const device_type R5000BE = &legacy_device_creator_drc<r5000be_int_device, r5000be_drc_device>; |
| 2777 | | const device_type R5000LE = &legacy_device_creator_drc<r5000le_int_device, r5000le_drc_device>; |
| 2778 | | const device_type QED5271BE = &legacy_device_creator_drc<qed5271be_int_device, qed5271be_drc_device>; |
| 2779 | | const device_type QED5271LE = &legacy_device_creator_drc<qed5271le_int_device, qed5271le_drc_device>; |
| 2780 | | const device_type RM7000BE = &legacy_device_creator_drc<rm7000be_int_device, rm7000be_drc_device>; |
| 2781 | | const device_type RM7000LE = &legacy_device_creator_drc<rm7000le_int_device, rm7000le_drc_device>; |
trunk/src/emu/cpu/mips/mips3drc.c
| r30757 | r30758 | |
| 35 | 35 | |
| 36 | 36 | using namespace uml; |
| 37 | 37 | |
| 38 | | /*************************************************************************** |
| 39 | | DEBUGGING |
| 40 | | ***************************************************************************/ |
| 41 | 38 | |
| 42 | | #define LOG_UML (0) |
| 43 | | #define LOG_NATIVE (0) |
| 44 | | |
| 45 | | #define DISABLE_FAST_REGISTERS (0) |
| 46 | | #define SINGLE_INSTRUCTION_MODE (0) |
| 47 | | |
| 48 | | #define PRINTF_EXCEPTIONS (0) |
| 49 | | #define PRINTF_MMU (0) |
| 50 | | |
| 51 | | #define PROBE_ADDRESS ~0 |
| 52 | | |
| 53 | | |
| 54 | | |
| 55 | 39 | /*************************************************************************** |
| 56 | | CONSTANTS |
| 57 | | ***************************************************************************/ |
| 58 | | |
| 59 | | /* map variables */ |
| 60 | | #define MAPVAR_PC M0 |
| 61 | | #define MAPVAR_CYCLES M1 |
| 62 | | |
| 63 | | /* modes */ |
| 64 | | #define MODE_KERNEL 0 |
| 65 | | #define MODE_SUPER 1 |
| 66 | | #define MODE_USER 2 |
| 67 | | |
| 68 | | /* size of the execution code cache */ |
| 69 | | #define CACHE_SIZE (32 * 1024 * 1024) |
| 70 | | |
| 71 | | /* compilation boundaries -- how far back/forward does the analysis extend? */ |
| 72 | | #define COMPILE_BACKWARDS_BYTES 128 |
| 73 | | #define COMPILE_FORWARDS_BYTES 512 |
| 74 | | #define COMPILE_MAX_INSTRUCTIONS ((COMPILE_BACKWARDS_BYTES/4) + (COMPILE_FORWARDS_BYTES/4)) |
| 75 | | #define COMPILE_MAX_SEQUENCE 64 |
| 76 | | |
| 77 | | /* exit codes */ |
| 78 | | #define EXECUTE_OUT_OF_CYCLES 0 |
| 79 | | #define EXECUTE_MISSING_CODE 1 |
| 80 | | #define EXECUTE_UNMAPPED_CODE 2 |
| 81 | | #define EXECUTE_RESET_CACHE 3 |
| 82 | | |
| 83 | | |
| 84 | | |
| 85 | | /*************************************************************************** |
| 86 | 40 | MACROS |
| 87 | 41 | ***************************************************************************/ |
| 88 | 42 | |
| 89 | | #define LOPTR(x) ((UINT32 *)(x) + NATIVE_ENDIAN_VALUE_LE_BE(0,1)) |
| 90 | | |
| 91 | | #define R32(reg) mips3->impstate->regmaplo[reg] |
| 43 | #define R32(reg) m_regmaplo[reg] |
| 92 | 44 | #define LO32 R32(REG_LO) |
| 93 | 45 | #define HI32 R32(REG_HI) |
| 94 | | #define CPR032(reg) mem(LOPTR(&mips3->cpr[0][reg])) |
| 95 | | #define CCR032(reg) mem(LOPTR(&mips3->ccr[0][reg])) |
| 96 | | #define FPR32(reg) mem(((mips3->impstate->mode & 1) == 0) ? &((float *)&mips3->cpr[1][0])[reg] : (float *)&mips3->cpr[1][reg]) |
| 97 | | #define CCR132(reg) mem(LOPTR(&mips3->ccr[1][reg])) |
| 98 | | #define CPR232(reg) mem(LOPTR(&mips3->cpr[2][reg])) |
| 99 | | #define CCR232(reg) mem(LOPTR(&mips3->ccr[2][reg])) |
| 46 | #define CPR032(reg) mem(LOPTR(&m_core->cpr[0][reg])) |
| 47 | #define CCR032(reg) mem(LOPTR(&m_core->ccr[0][reg])) |
| 48 | #define FPR32(reg) mem(((m_core->mode & 1) == 0) ? &((float *)&m_core->cpr[1][0])[reg] : (float *)&m_core->cpr[1][reg]) |
| 49 | #define CCR132(reg) mem(LOPTR(&m_core->ccr[1][reg])) |
| 50 | #define CPR232(reg) mem(LOPTR(&m_core->cpr[2][reg])) |
| 51 | #define CCR232(reg) mem(LOPTR(&m_core->ccr[2][reg])) |
| 100 | 52 | |
| 101 | | #define R64(reg) mips3->impstate->regmap[reg] |
| 53 | #define R64(reg) m_regmap[reg] |
| 102 | 54 | #define LO64 R64(REG_LO) |
| 103 | 55 | #define HI64 R64(REG_HI) |
| 104 | | #define CPR064(reg) mem(&mips3->cpr[0][reg]) |
| 105 | | #define CCR064(reg) mem(&mips3->ccr[0][reg]) |
| 106 | | #define FPR64(reg) mem(((mips3->impstate->mode & 1) == 0) ? (double *)&mips3->cpr[1][(reg)/2] : (double *)&mips3->cpr[1][reg]) |
| 107 | | #define CCR164(reg) mem(&mips3->ccr[1][reg]) |
| 108 | | #define CPR264(reg) mem(&mips3->cpr[2][reg]) |
| 109 | | #define CCR264(reg) mem(&mips3->ccr[2][reg]) |
| 56 | #define CPR064(reg) mem(&m_core->cpr[0][reg]) |
| 57 | #define CCR064(reg) mem(&m_core->ccr[0][reg]) |
| 58 | #define FPR64(reg) mem(((m_core->mode & 1) == 0) ? (double *)&m_core->cpr[1][(reg)/2] : (double *)&m_core->cpr[1][reg]) |
| 59 | #define CCR164(reg) mem(&m_core->ccr[1][reg]) |
| 60 | #define CPR264(reg) mem(&m_core->cpr[2][reg]) |
| 61 | #define CCR264(reg) mem(&m_core->ccr[2][reg]) |
| 110 | 62 | |
| 111 | | #define FCCSHIFT(which) fcc_shift[(mips3->flavor < MIPS3_TYPE_MIPS_IV) ? 0 : ((which) & 7)] |
| 63 | #define FCCSHIFT(which) fcc_shift[(m_flavor < MIPS3_TYPE_MIPS_IV) ? 0 : ((which) & 7)] |
| 112 | 64 | #define FCCMASK(which) ((UINT32)(1 << FCCSHIFT(which))) |
| 113 | 65 | |
| 114 | 66 | |
| 115 | 67 | |
| 116 | 68 | /*************************************************************************** |
| 117 | | STRUCTURES & TYPEDEFS |
| 118 | | ***************************************************************************/ |
| 119 | | |
| 120 | | /* fast RAM info */ |
| 121 | | struct fast_ram_info |
| 122 | | { |
| 123 | | offs_t start; /* start of the RAM block */ |
| 124 | | offs_t end; /* end of the RAM block */ |
| 125 | | UINT8 readonly; /* TRUE if read-only */ |
| 126 | | void * base; /* base in memory where the RAM lives */ |
| 127 | | }; |
| 128 | | |
| 129 | | |
| 130 | | /* hotspot info */ |
| 131 | | struct hotspot_info |
| 132 | | { |
| 133 | | offs_t pc; /* PC to consider */ |
| 134 | | UINT32 opcode; /* required opcode at that PC */ |
| 135 | | UINT32 cycles; /* number of cycles to eat when hit */ |
| 136 | | }; |
| 137 | | |
| 138 | | |
| 139 | | /* internal compiler state */ |
| 140 | | struct compiler_state |
| 141 | | { |
| 142 | | UINT32 cycles; /* accumulated cycles */ |
| 143 | | UINT8 checkints; /* need to check interrupts before next instruction */ |
| 144 | | UINT8 checksoftints; /* need to check software interrupts before next instruction */ |
| 145 | | code_label labelnum; /* index for local labels */ |
| 146 | | }; |
| 147 | | |
| 148 | | |
| 149 | | /* MIPS3 registers */ |
| 150 | | struct mips3imp_state |
| 151 | | { |
| 152 | | /* core state */ |
| 153 | | drc_cache * cache; /* pointer to the DRC code cache */ |
| 154 | | drcuml_state * drcuml; /* DRC UML generator state */ |
| 155 | | mips3_frontend * drcfe; /* pointer to the DRC front-end state */ |
| 156 | | UINT32 drcoptions; /* configurable DRC options */ |
| 157 | | |
| 158 | | /* internal stuff */ |
| 159 | | UINT8 cache_dirty; /* true if we need to flush the cache */ |
| 160 | | UINT32 jmpdest; /* destination jump target */ |
| 161 | | |
| 162 | | /* parameters for subroutines */ |
| 163 | | UINT64 numcycles; /* return value from gettotalcycles */ |
| 164 | | UINT32 mode; /* current global mode */ |
| 165 | | const char * format; /* format string for print_debug */ |
| 166 | | UINT32 arg0; /* print_debug argument 1 */ |
| 167 | | UINT32 arg1; /* print_debug argument 2 */ |
| 168 | | |
| 169 | | /* tables */ |
| 170 | | UINT8 fpmode[4]; /* FPU mode table */ |
| 171 | | |
| 172 | | /* register mappings */ |
| 173 | | parameter regmap[34]; /* parameter to register mappings for all 32 integer registers */ |
| 174 | | parameter regmaplo[34]; /* parameter to register mappings for all 32 integer registers */ |
| 175 | | |
| 176 | | /* subroutines */ |
| 177 | | code_handle * entry; /* entry point */ |
| 178 | | code_handle * nocode; /* nocode exception handler */ |
| 179 | | code_handle * out_of_cycles; /* out of cycles exception handler */ |
| 180 | | code_handle * tlb_mismatch; /* tlb mismatch handler */ |
| 181 | | code_handle * read8[3]; /* read byte */ |
| 182 | | code_handle * write8[3]; /* write byte */ |
| 183 | | code_handle * read16[3]; /* read half */ |
| 184 | | code_handle * write16[3]; /* write half */ |
| 185 | | code_handle * read32[3]; /* read word */ |
| 186 | | code_handle * read32mask[3]; /* read word masked */ |
| 187 | | code_handle * write32[3]; /* write word */ |
| 188 | | code_handle * write32mask[3]; /* write word masked */ |
| 189 | | code_handle * read64[3]; /* read double */ |
| 190 | | code_handle * read64mask[3]; /* read double masked */ |
| 191 | | code_handle * write64[3]; /* write double */ |
| 192 | | code_handle * write64mask[3]; /* write double masked */ |
| 193 | | code_handle * exception[EXCEPTION_COUNT]; /* array of exception handlers */ |
| 194 | | code_handle * exception_norecover[EXCEPTION_COUNT]; /* array of no-recover exception handlers */ |
| 195 | | |
| 196 | | /* fast RAM */ |
| 197 | | UINT32 fastram_select; |
| 198 | | fast_ram_info fastram[MIPS3_MAX_FASTRAM]; |
| 199 | | |
| 200 | | /* hotspots */ |
| 201 | | UINT32 hotspot_select; |
| 202 | | hotspot_info hotspot[MIPS3_MAX_HOTSPOTS]; |
| 203 | | }; |
| 204 | | |
| 205 | | |
| 206 | | |
| 207 | | /*************************************************************************** |
| 208 | 69 | FUNCTION PROTOTYPES |
| 209 | 70 | ***************************************************************************/ |
| 210 | 71 | |
| 211 | | static void code_flush_cache(mips3_state *mips3); |
| 212 | | static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc); |
| 213 | | |
| 214 | 72 | static void cfunc_printf_exception(void *param); |
| 215 | 73 | static void cfunc_get_cycles(void *param); |
| 216 | 74 | static void cfunc_printf_probe(void *param); |
| 217 | 75 | |
| 218 | | static void static_generate_entry_point(mips3_state *mips3); |
| 219 | | static void static_generate_nocode_handler(mips3_state *mips3); |
| 220 | | static void static_generate_out_of_cycles(mips3_state *mips3); |
| 221 | | static void static_generate_tlb_mismatch(mips3_state *mips3); |
| 222 | | static void static_generate_exception(mips3_state *mips3, UINT8 exception, int recover, const char *name); |
| 223 | | static void static_generate_memory_accessor(mips3_state *mips3, int mode, int size, int iswrite, int ismasked, const char *name, code_handle **handleptr); |
| 224 | 76 | |
| 225 | | static void generate_update_mode(mips3_state *mips3, drcuml_block *block); |
| 226 | | static void generate_update_cycles(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, parameter param, int allow_exception); |
| 227 | | static void generate_checksum_block(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast); |
| 228 | | static void generate_sequence_instruction(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 229 | | static void generate_delay_slot_and_branch(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 linkreg); |
| 230 | | static int generate_opcode(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 231 | | static int generate_special(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 232 | | static int generate_regimm(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 233 | | static int generate_idt(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 234 | | static int generate_set_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg); |
| 235 | | static int generate_get_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg); |
| 236 | | static int generate_cop0(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 237 | | static int generate_cop1(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 238 | | static int generate_cop1x(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 239 | | |
| 240 | | static void log_add_disasm_comment(mips3_state *mips3, drcuml_block *block, UINT32 pc, UINT32 op); |
| 241 | | static const char *log_desc_flags_to_string(UINT32 flags); |
| 242 | | static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist); |
| 243 | | static void log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, int indent); |
| 244 | | |
| 245 | | |
| 246 | | |
| 247 | 77 | /*************************************************************************** |
| 248 | 78 | PRIVATE GLOBAL VARIABLES |
| 249 | 79 | ***************************************************************************/ |
| r30757 | r30758 | |
| 251 | 81 | /* bit indexes for various FCCs */ |
| 252 | 82 | static const UINT8 fcc_shift[8] = { 23, 25, 26, 27, 28, 29, 30, 31 }; |
| 253 | 83 | |
| 254 | | /* lookup table for FP modes */ |
| 255 | | static const UINT8 fpmode_source[4] = |
| 256 | | { |
| 257 | | ROUND_ROUND, |
| 258 | | ROUND_TRUNC, |
| 259 | | ROUND_CEIL, |
| 260 | | ROUND_FLOOR |
| 261 | | }; |
| 262 | 84 | |
| 263 | | |
| 264 | | |
| 265 | 85 | /*************************************************************************** |
| 266 | 86 | INLINE FUNCTIONS |
| 267 | 87 | ***************************************************************************/ |
| 268 | 88 | |
| 269 | | INLINE mips3_state *get_safe_token(device_t *device) |
| 270 | | { |
| 271 | | assert(device != NULL); |
| 272 | | assert(device->type() == VR4300BE_DRC || |
| 273 | | device->type() == VR4300LE_DRC || |
| 274 | | device->type() == VR4310BE_DRC || |
| 275 | | device->type() == VR4310LE_DRC || |
| 276 | | device->type() == R4600BE_DRC || |
| 277 | | device->type() == R4600LE_DRC || |
| 278 | | device->type() == R4650BE_DRC || |
| 279 | | device->type() == R4650LE_DRC || |
| 280 | | device->type() == R4700BE_DRC || |
| 281 | | device->type() == R4700LE_DRC || |
| 282 | | device->type() == R5000BE_DRC || |
| 283 | | device->type() == R5000LE_DRC || |
| 284 | | device->type() == QED5271BE_DRC || |
| 285 | | device->type() == QED5271LE_DRC || |
| 286 | | device->type() == RM7000BE_DRC || |
| 287 | | device->type() == RM7000LE_DRC); |
| 288 | | return *(mips3_state **)downcast<legacy_cpu_device *>(device)->token(); |
| 289 | | } |
| 290 | | |
| 291 | | |
| 292 | 89 | /*------------------------------------------------- |
| 293 | 90 | epc - compute the exception PC from a |
| 294 | 91 | descriptor |
| r30757 | r30758 | |
| 317 | 114 | registers |
| 318 | 115 | -------------------------------------------------*/ |
| 319 | 116 | |
| 320 | | INLINE void load_fast_iregs(mips3_state *mips3, drcuml_block *block) |
| 117 | inline void mips3_device::load_fast_iregs(drcuml_block *block) |
| 321 | 118 | { |
| 322 | 119 | int regnum; |
| 323 | 120 | |
| 324 | | for (regnum = 0; regnum < ARRAY_LENGTH(mips3->impstate->regmap); regnum++) |
| 325 | | if (mips3->impstate->regmap[regnum].is_int_register()) |
| 326 | | UML_DMOV(block, ireg(mips3->impstate->regmap[regnum].ireg() - REG_I0), mem(&mips3->r[regnum])); |
| 121 | for (regnum = 0; regnum < ARRAY_LENGTH(m_regmap); regnum++) |
| 122 | if (m_regmap[regnum].is_int_register()) |
| 123 | UML_DMOV(block, ireg(m_regmap[regnum].ireg() - REG_I0), mem(&m_core->r[regnum])); |
| 327 | 124 | } |
| 328 | 125 | |
| 329 | 126 | |
| r30757 | r30758 | |
| 332 | 129 | registers |
| 333 | 130 | -------------------------------------------------*/ |
| 334 | 131 | |
| 335 | | INLINE void save_fast_iregs(mips3_state *mips3, drcuml_block *block) |
| 132 | inline void mips3_device::save_fast_iregs(drcuml_block *block) |
| 336 | 133 | { |
| 337 | 134 | int regnum; |
| 338 | 135 | |
| 339 | | for (regnum = 0; regnum < ARRAY_LENGTH(mips3->impstate->regmap); regnum++) |
| 340 | | if (mips3->impstate->regmap[regnum].is_int_register()) |
| 341 | | UML_DMOV(block, mem(&mips3->r[regnum]), ireg(mips3->impstate->regmap[regnum].ireg() - REG_I0)); |
| 136 | for (regnum = 0; regnum < ARRAY_LENGTH(m_regmap); regnum++) |
| 137 | if (m_regmap[regnum].is_int_register()) |
| 138 | UML_DMOV(block, mem(&m_core->r[regnum]), ireg(m_regmap[regnum].ireg() - REG_I0)); |
| 342 | 139 | } |
| 343 | 140 | |
| 344 | 141 | |
| r30757 | r30758 | |
| 348 | 145 | ***************************************************************************/ |
| 349 | 146 | |
| 350 | 147 | /*------------------------------------------------- |
| 351 | | mips3_init - initialize the processor |
| 352 | | -------------------------------------------------*/ |
| 353 | | |
| 354 | | static void mips3_init(mips3_flavor flavor, int bigendian, legacy_cpu_device *device, device_irq_acknowledge_delegate irqcallback) |
| 355 | | { |
| 356 | | mips3_state *mips3; |
| 357 | | drc_cache *cache; |
| 358 | | drcbe_info beinfo; |
| 359 | | UINT32 flags = 0; |
| 360 | | int regnum; |
| 361 | | |
| 362 | | /* allocate enough space for the cache and the core */ |
| 363 | | cache = auto_alloc(device->machine(), drc_cache(CACHE_SIZE + sizeof(*mips3))); |
| 364 | | if (cache == NULL) |
| 365 | | fatalerror("Unable to allocate cache of size %d\n", (UINT32)(CACHE_SIZE + sizeof(*mips3))); |
| 366 | | |
| 367 | | /* allocate the core memory */ |
| 368 | | *(mips3_state **)device->token() = mips3 = (mips3_state *)cache->alloc_near(sizeof(*mips3)); |
| 369 | | memset(mips3, 0, sizeof(*mips3)); |
| 370 | | |
| 371 | | /* initialize the core */ |
| 372 | | mips3com_init(mips3, flavor, bigendian, device, irqcallback); |
| 373 | | |
| 374 | | /* allocate the implementation-specific state from the full cache */ |
| 375 | | mips3->impstate = (mips3imp_state *)cache->alloc_near(sizeof(*mips3->impstate)); |
| 376 | | memset(mips3->impstate, 0, sizeof(*mips3->impstate)); |
| 377 | | mips3->impstate->cache = cache; |
| 378 | | |
| 379 | | /* initialize the UML generator */ |
| 380 | | if (LOG_UML) |
| 381 | | flags |= DRCUML_OPTION_LOG_UML; |
| 382 | | if (LOG_NATIVE) |
| 383 | | flags |= DRCUML_OPTION_LOG_NATIVE; |
| 384 | | mips3->impstate->drcuml = auto_alloc(device->machine(), drcuml_state(*device, *cache, flags, 8, 32, 2)); |
| 385 | | |
| 386 | | /* add symbols for our stuff */ |
| 387 | | mips3->impstate->drcuml->symbol_add(&mips3->pc, sizeof(mips3->pc), "pc"); |
| 388 | | mips3->impstate->drcuml->symbol_add(&mips3->icount, sizeof(mips3->icount), "icount"); |
| 389 | | for (regnum = 0; regnum < 32; regnum++) |
| 390 | | { |
| 391 | | char buf[10]; |
| 392 | | sprintf(buf, "r%d", regnum); |
| 393 | | mips3->impstate->drcuml->symbol_add(&mips3->r[regnum], sizeof(mips3->r[regnum]), buf); |
| 394 | | sprintf(buf, "f%d", regnum); |
| 395 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[1][regnum], sizeof(mips3->cpr[1][regnum]), buf); |
| 396 | | } |
| 397 | | mips3->impstate->drcuml->symbol_add(&mips3->r[REG_LO], sizeof(mips3->r[REG_LO]), "lo"); |
| 398 | | mips3->impstate->drcuml->symbol_add(&mips3->r[REG_HI], sizeof(mips3->r[REG_LO]), "hi"); |
| 399 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Index], sizeof(mips3->cpr[0][COP0_Index]), "Index"); |
| 400 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Random], sizeof(mips3->cpr[0][COP0_Random]), "Random"); |
| 401 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_EntryLo0], sizeof(mips3->cpr[0][COP0_EntryLo0]), "EntryLo0"); |
| 402 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_EntryLo1], sizeof(mips3->cpr[0][COP0_EntryLo1]), "EntryLo1"); |
| 403 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Context], sizeof(mips3->cpr[0][COP0_Context]), "Context"); |
| 404 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_PageMask], sizeof(mips3->cpr[0][COP0_PageMask]), "PageMask"); |
| 405 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Wired], sizeof(mips3->cpr[0][COP0_Wired]), "Wired"); |
| 406 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_BadVAddr], sizeof(mips3->cpr[0][COP0_BadVAddr]), "BadVAddr"); |
| 407 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Count], sizeof(mips3->cpr[0][COP0_Count]), "Count"); |
| 408 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_EntryHi], sizeof(mips3->cpr[0][COP0_EntryHi]), "EntryHi"); |
| 409 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Compare], sizeof(mips3->cpr[0][COP0_Compare]), "Compare"); |
| 410 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Status], sizeof(mips3->cpr[0][COP0_Status]), "Status"); |
| 411 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Cause], sizeof(mips3->cpr[0][COP0_Cause]), "Cause"); |
| 412 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_EPC], sizeof(mips3->cpr[0][COP0_EPC]), "EPC"); |
| 413 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_PRId], sizeof(mips3->cpr[0][COP0_PRId]), "PRId"); |
| 414 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_Config], sizeof(mips3->cpr[0][COP0_Config]), "Config"); |
| 415 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_LLAddr], sizeof(mips3->cpr[0][COP0_LLAddr]), "LLAddr"); |
| 416 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_XContext], sizeof(mips3->cpr[0][COP0_XContext]), "XContext"); |
| 417 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_ECC], sizeof(mips3->cpr[0][COP0_ECC]), "ECC"); |
| 418 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_CacheErr], sizeof(mips3->cpr[0][COP0_CacheErr]), "CacheErr"); |
| 419 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_TagLo], sizeof(mips3->cpr[0][COP0_TagLo]), "TagLo"); |
| 420 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_TagHi], sizeof(mips3->cpr[0][COP0_TagHi]), "TagHi"); |
| 421 | | mips3->impstate->drcuml->symbol_add(&mips3->cpr[0][COP0_ErrorPC], sizeof(mips3->cpr[0][COP0_ErrorPC]), "ErrorPC"); |
| 422 | | mips3->impstate->drcuml->symbol_add(&mips3->ccr[1][31], sizeof(mips3->cpr[1][31]), "fcr31"); |
| 423 | | mips3->impstate->drcuml->symbol_add(&mips3->impstate->mode, sizeof(mips3->impstate->mode), "mode"); |
| 424 | | mips3->impstate->drcuml->symbol_add(&mips3->impstate->arg0, sizeof(mips3->impstate->arg0), "arg0"); |
| 425 | | mips3->impstate->drcuml->symbol_add(&mips3->impstate->arg1, sizeof(mips3->impstate->arg1), "arg1"); |
| 426 | | mips3->impstate->drcuml->symbol_add(&mips3->impstate->numcycles, sizeof(mips3->impstate->numcycles), "numcycles"); |
| 427 | | mips3->impstate->drcuml->symbol_add(&mips3->impstate->fpmode, sizeof(mips3->impstate->fpmode), "fpmode"); |
| 428 | | |
| 429 | | /* initialize the front-end helper */ |
| 430 | | mips3->impstate->drcfe = auto_alloc(device->machine(), mips3_frontend(*mips3, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE)); |
| 431 | | |
| 432 | | /* allocate memory for cache-local state and initialize it */ |
| 433 | | memcpy(mips3->impstate->fpmode, fpmode_source, sizeof(fpmode_source)); |
| 434 | | |
| 435 | | /* compute the register parameters */ |
| 436 | | for (regnum = 0; regnum < 34; regnum++) |
| 437 | | { |
| 438 | | mips3->impstate->regmap[regnum] = (regnum == 0) ? parameter(0) : parameter::make_memory(&mips3->r[regnum]); |
| 439 | | mips3->impstate->regmaplo[regnum] = (regnum == 0) ? parameter(0) : parameter::make_memory(LOPTR(&mips3->r[regnum])); |
| 440 | | } |
| 441 | | |
| 442 | | /* if we have registers to spare, assign r2, r3, r4 to leftovers */ |
| 443 | | if (!DISABLE_FAST_REGISTERS) |
| 444 | | { |
| 445 | | mips3->impstate->drcuml->get_backend_info(beinfo); |
| 446 | | if (beinfo.direct_iregs > 4) |
| 447 | | { |
| 448 | | mips3->impstate->regmap[2] = I4; |
| 449 | | mips3->impstate->regmaplo[2] = I4; |
| 450 | | } |
| 451 | | if (beinfo.direct_iregs > 5) |
| 452 | | { |
| 453 | | mips3->impstate->regmap[3] = I5; |
| 454 | | mips3->impstate->regmaplo[3] = I5; |
| 455 | | } |
| 456 | | if (beinfo.direct_iregs > 6) |
| 457 | | { |
| 458 | | mips3->impstate->regmap[4] = I6; |
| 459 | | mips3->impstate->regmaplo[4] = I6; |
| 460 | | } |
| 461 | | } |
| 462 | | |
| 463 | | /* mark the cache dirty so it is updated on next execute */ |
| 464 | | mips3->impstate->cache_dirty = TRUE; |
| 465 | | } |
| 466 | | |
| 467 | | |
| 468 | | /*------------------------------------------------- |
| 469 | | mips3_reset - reset the processor |
| 470 | | -------------------------------------------------*/ |
| 471 | | |
| 472 | | static CPU_RESET( mips3 ) |
| 473 | | { |
| 474 | | mips3_state *mips3 = get_safe_token(device); |
| 475 | | |
| 476 | | /* reset the common code and mark the cache dirty */ |
| 477 | | mips3com_reset(mips3); |
| 478 | | mips3->impstate->mode = (MODE_KERNEL << 1) | 0; |
| 479 | | mips3->impstate->cache_dirty = TRUE; |
| 480 | | } |
| 481 | | |
| 482 | | |
| 483 | | /*------------------------------------------------- |
| 484 | | mips3_execute - execute the CPU for the |
| 485 | | specified number of cycles |
| 486 | | -------------------------------------------------*/ |
| 487 | | |
| 488 | | static CPU_EXECUTE( mips3 ) |
| 489 | | { |
| 490 | | mips3_state *mips3 = get_safe_token(device); |
| 491 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 492 | | int execute_result; |
| 493 | | |
| 494 | | /* reset the cache if dirty */ |
| 495 | | if (mips3->impstate->cache_dirty) |
| 496 | | code_flush_cache(mips3); |
| 497 | | mips3->impstate->cache_dirty = FALSE; |
| 498 | | |
| 499 | | /* execute */ |
| 500 | | do |
| 501 | | { |
| 502 | | /* run as much as we can */ |
| 503 | | execute_result = drcuml->execute(*mips3->impstate->entry); |
| 504 | | |
| 505 | | /* if we need to recompile, do it */ |
| 506 | | if (execute_result == EXECUTE_MISSING_CODE) |
| 507 | | code_compile_block(mips3, mips3->impstate->mode, mips3->pc); |
| 508 | | else if (execute_result == EXECUTE_UNMAPPED_CODE) |
| 509 | | fatalerror("Attempted to execute unmapped code at PC=%08X\n", mips3->pc); |
| 510 | | else if (execute_result == EXECUTE_RESET_CACHE) |
| 511 | | code_flush_cache(mips3); |
| 512 | | |
| 513 | | } while (execute_result != EXECUTE_OUT_OF_CYCLES); |
| 514 | | } |
| 515 | | |
| 516 | | |
| 517 | | /*------------------------------------------------- |
| 518 | | mips3_exit - cleanup from execution |
| 519 | | -------------------------------------------------*/ |
| 520 | | |
| 521 | | static CPU_EXIT( mips3 ) |
| 522 | | { |
| 523 | | mips3_state *mips3 = get_safe_token(device); |
| 524 | | mips3com_exit(mips3); |
| 525 | | |
| 526 | | /* clean up the DRC */ |
| 527 | | auto_free(device->machine(), mips3->impstate->drcfe); |
| 528 | | auto_free(device->machine(), mips3->impstate->drcuml); |
| 529 | | auto_free(device->machine(), mips3->impstate->cache); |
| 530 | | } |
| 531 | | |
| 532 | | |
| 533 | | /*------------------------------------------------- |
| 534 | | mips3_translate - perform virtual-to-physical |
| 535 | | address translation |
| 536 | | -------------------------------------------------*/ |
| 537 | | |
| 538 | | static CPU_TRANSLATE( mips3 ) |
| 539 | | { |
| 540 | | mips3_state *mips3 = get_safe_token(device); |
| 541 | | return mips3com_translate_address(mips3, space, intention, address); |
| 542 | | } |
| 543 | | |
| 544 | | |
| 545 | | /*------------------------------------------------- |
| 546 | | mips3_dasm - disassemble an instruction |
| 547 | | -------------------------------------------------*/ |
| 548 | | |
| 549 | | static CPU_DISASSEMBLE( mips3 ) |
| 550 | | { |
| 551 | | mips3_state *mips3 = get_safe_token(device); |
| 552 | | return mips3com_dasm(mips3, buffer, pc, oprom, opram); |
| 553 | | } |
| 554 | | |
| 555 | | |
| 556 | | /*------------------------------------------------- |
| 557 | | mips3_set_info - set information about a given |
| 558 | | CPU instance |
| 559 | | -------------------------------------------------*/ |
| 560 | | |
| 561 | | static CPU_SET_INFO( mips3 ) |
| 562 | | { |
| 563 | | mips3_state *mips3 = get_safe_token(device); |
| 564 | | |
| 565 | | /* --- everything is handled generically --- */ |
| 566 | | mips3com_set_info(mips3, state, info); |
| 567 | | } |
| 568 | | |
| 569 | | |
| 570 | | /*------------------------------------------------- |
| 571 | | mips3_get_info - return information about a |
| 572 | | given CPU instance |
| 573 | | -------------------------------------------------*/ |
| 574 | | |
| 575 | | static CPU_GET_INFO( mips3 ) |
| 576 | | { |
| 577 | | mips3_state *mips3 = (device != NULL && device->token() != NULL) ? get_safe_token(device) : NULL; |
| 578 | | switch (state) |
| 579 | | { |
| 580 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 581 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(mips3_state *); break; |
| 582 | | case CPUINFO_INT_PREVIOUSPC: /* not implemented */ break; |
| 583 | | |
| 584 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 585 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(mips3); break; |
| 586 | | case CPUINFO_FCT_INIT: /* provided per-CPU */ break; |
| 587 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(mips3); break; |
| 588 | | case CPUINFO_FCT_EXIT: info->exit = CPU_EXIT_NAME(mips3); break; |
| 589 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(mips3); break; |
| 590 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(mips3);break; |
| 591 | | case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(mips3); break; |
| 592 | | |
| 593 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 594 | | case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 595 | | |
| 596 | | /* --- everything else is handled generically --- */ |
| 597 | | default: mips3com_get_info(mips3, state, info); break; |
| 598 | | } |
| 599 | | } |
| 600 | | |
| 601 | | |
| 602 | | /*------------------------------------------------- |
| 603 | 148 | mips3drc_set_options - configure DRC options |
| 604 | 149 | -------------------------------------------------*/ |
| 605 | 150 | |
| 606 | | void mips3drc_set_options(device_t *device, UINT32 options) |
| 151 | void mips3_device::mips3drc_set_options(UINT32 options) |
| 607 | 152 | { |
| 608 | | if (!device->machine().options().drc()) return; |
| 609 | | mips3_state *mips3 = get_safe_token(device); |
| 610 | | mips3->impstate->drcoptions = options; |
| 153 | if (!machine().options().drc()) return; |
| 154 | m_drcoptions = options; |
| 611 | 155 | } |
| 612 | 156 | |
| 613 | 157 | |
| r30757 | r30758 | |
| 616 | 160 | region |
| 617 | 161 | -------------------------------------------------*/ |
| 618 | 162 | |
| 619 | | void mips3drc_add_fastram(device_t *device, offs_t start, offs_t end, UINT8 readonly, void *base) |
| 163 | void mips3_device::mips3drc_add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base) |
| 620 | 164 | { |
| 621 | | if (!device->machine().options().drc()) return; |
| 622 | | mips3_state *mips3 = get_safe_token(device); |
| 623 | | if (mips3->impstate->fastram_select < ARRAY_LENGTH(mips3->impstate->fastram)) |
| 165 | if (!machine().options().drc()) return; |
| 166 | if (m_fastram_select < ARRAY_LENGTH(m_fastram)) |
| 624 | 167 | { |
| 625 | | mips3->impstate->fastram[mips3->impstate->fastram_select].start = start; |
| 626 | | mips3->impstate->fastram[mips3->impstate->fastram_select].end = end; |
| 627 | | mips3->impstate->fastram[mips3->impstate->fastram_select].readonly = readonly; |
| 628 | | mips3->impstate->fastram[mips3->impstate->fastram_select].base = base; |
| 629 | | mips3->impstate->fastram_select++; |
| 168 | m_fastram[m_fastram_select].start = start; |
| 169 | m_fastram[m_fastram_select].end = end; |
| 170 | m_fastram[m_fastram_select].readonly = readonly; |
| 171 | m_fastram[m_fastram_select].base = base; |
| 172 | m_fastram_select++; |
| 630 | 173 | } |
| 631 | 174 | } |
| 632 | 175 | |
| r30757 | r30758 | |
| 635 | 178 | mips3drc_add_hotspot - add a new hotspot |
| 636 | 179 | -------------------------------------------------*/ |
| 637 | 180 | |
| 638 | | void mips3drc_add_hotspot(device_t *device, offs_t pc, UINT32 opcode, UINT32 cycles) |
| 181 | void mips3_device::mips3drc_add_hotspot(offs_t pc, UINT32 opcode, UINT32 cycles) |
| 639 | 182 | { |
| 640 | | if (!device->machine().options().drc()) return; |
| 641 | | mips3_state *mips3 = get_safe_token(device); |
| 642 | | if (mips3->impstate->hotspot_select < ARRAY_LENGTH(mips3->impstate->hotspot)) |
| 183 | if (!machine().options().drc()) return; |
| 184 | if (m_hotspot_select < ARRAY_LENGTH(m_hotspot)) |
| 643 | 185 | { |
| 644 | | mips3->impstate->hotspot[mips3->impstate->hotspot_select].pc = pc; |
| 645 | | mips3->impstate->hotspot[mips3->impstate->hotspot_select].opcode = opcode; |
| 646 | | mips3->impstate->hotspot[mips3->impstate->hotspot_select].cycles = cycles; |
| 647 | | mips3->impstate->hotspot_select++; |
| 186 | m_hotspot[m_hotspot_select].pc = pc; |
| 187 | m_hotspot[m_hotspot_select].opcode = opcode; |
| 188 | m_hotspot[m_hotspot_select].cycles = cycles; |
| 189 | m_hotspot_select++; |
| 648 | 190 | } |
| 649 | 191 | } |
| 650 | 192 | |
| r30757 | r30758 | |
| 659 | 201 | regenerate static code |
| 660 | 202 | -------------------------------------------------*/ |
| 661 | 203 | |
| 662 | | static void code_flush_cache(mips3_state *mips3) |
| 204 | void mips3_device::code_flush_cache() |
| 663 | 205 | { |
| 664 | 206 | int mode; |
| 665 | 207 | |
| 666 | 208 | /* empty the transient cache contents */ |
| 667 | | mips3->impstate->drcuml->reset(); |
| 209 | m_drcuml->reset(); |
| 668 | 210 | |
| 669 | 211 | try |
| 670 | 212 | { |
| 671 | 213 | /* generate the entry point and out-of-cycles handlers */ |
| 672 | | static_generate_entry_point(mips3); |
| 673 | | static_generate_nocode_handler(mips3); |
| 674 | | static_generate_out_of_cycles(mips3); |
| 675 | | static_generate_tlb_mismatch(mips3); |
| 214 | static_generate_entry_point(); |
| 215 | static_generate_nocode_handler(); |
| 216 | static_generate_out_of_cycles(); |
| 217 | static_generate_tlb_mismatch(); |
| 676 | 218 | |
| 677 | 219 | /* append exception handlers for various types */ |
| 678 | | static_generate_exception(mips3, EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); |
| 679 | | static_generate_exception(mips3, EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); |
| 680 | | static_generate_exception(mips3, EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); |
| 681 | | static_generate_exception(mips3, EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); |
| 682 | | static_generate_exception(mips3, EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); |
| 683 | | static_generate_exception(mips3, EXCEPTION_TLBLOAD_FILL, TRUE, "exception_tlbload_fill"); |
| 684 | | static_generate_exception(mips3, EXCEPTION_TLBSTORE_FILL, TRUE, "exception_tlbstore_fill"); |
| 685 | | static_generate_exception(mips3, EXCEPTION_ADDRLOAD, TRUE, "exception_addrload"); |
| 686 | | static_generate_exception(mips3, EXCEPTION_ADDRSTORE, TRUE, "exception_addrstore"); |
| 687 | | static_generate_exception(mips3, EXCEPTION_SYSCALL, TRUE, "exception_syscall"); |
| 688 | | static_generate_exception(mips3, EXCEPTION_BREAK, TRUE, "exception_break"); |
| 689 | | static_generate_exception(mips3, EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); |
| 690 | | static_generate_exception(mips3, EXCEPTION_BADCOP, TRUE, "exception_badcop"); |
| 691 | | static_generate_exception(mips3, EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); |
| 692 | | static_generate_exception(mips3, EXCEPTION_TRAP, TRUE, "exception_trap"); |
| 220 | static_generate_exception(EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); |
| 221 | static_generate_exception(EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); |
| 222 | static_generate_exception(EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); |
| 223 | static_generate_exception(EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); |
| 224 | static_generate_exception(EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); |
| 225 | static_generate_exception(EXCEPTION_TLBLOAD_FILL, TRUE, "exception_tlbload_fill"); |
| 226 | static_generate_exception(EXCEPTION_TLBSTORE_FILL, TRUE, "exception_tlbstore_fill"); |
| 227 | static_generate_exception(EXCEPTION_ADDRLOAD, TRUE, "exception_addrload"); |
| 228 | static_generate_exception(EXCEPTION_ADDRSTORE, TRUE, "exception_addrstore"); |
| 229 | static_generate_exception(EXCEPTION_SYSCALL, TRUE, "exception_syscall"); |
| 230 | static_generate_exception(EXCEPTION_BREAK, TRUE, "exception_break"); |
| 231 | static_generate_exception(EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); |
| 232 | static_generate_exception(EXCEPTION_BADCOP, TRUE, "exception_badcop"); |
| 233 | static_generate_exception(EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); |
| 234 | static_generate_exception(EXCEPTION_TRAP, TRUE, "exception_trap"); |
| 693 | 235 | |
| 694 | 236 | /* add subroutines for memory accesses */ |
| 695 | 237 | for (mode = 0; mode < 3; mode++) |
| 696 | 238 | { |
| 697 | | static_generate_memory_accessor(mips3, mode, 1, FALSE, FALSE, "read8", &mips3->impstate->read8[mode]); |
| 698 | | static_generate_memory_accessor(mips3, mode, 1, TRUE, FALSE, "write8", &mips3->impstate->write8[mode]); |
| 699 | | static_generate_memory_accessor(mips3, mode, 2, FALSE, FALSE, "read16", &mips3->impstate->read16[mode]); |
| 700 | | static_generate_memory_accessor(mips3, mode, 2, TRUE, FALSE, "write16", &mips3->impstate->write16[mode]); |
| 701 | | static_generate_memory_accessor(mips3, mode, 4, FALSE, FALSE, "read32", &mips3->impstate->read32[mode]); |
| 702 | | static_generate_memory_accessor(mips3, mode, 4, FALSE, TRUE, "read32mask", &mips3->impstate->read32mask[mode]); |
| 703 | | static_generate_memory_accessor(mips3, mode, 4, TRUE, FALSE, "write32", &mips3->impstate->write32[mode]); |
| 704 | | static_generate_memory_accessor(mips3, mode, 4, TRUE, TRUE, "write32mask", &mips3->impstate->write32mask[mode]); |
| 705 | | static_generate_memory_accessor(mips3, mode, 8, FALSE, FALSE, "read64", &mips3->impstate->read64[mode]); |
| 706 | | static_generate_memory_accessor(mips3, mode, 8, FALSE, TRUE, "read64mask", &mips3->impstate->read64mask[mode]); |
| 707 | | static_generate_memory_accessor(mips3, mode, 8, TRUE, FALSE, "write64", &mips3->impstate->write64[mode]); |
| 708 | | static_generate_memory_accessor(mips3, mode, 8, TRUE, TRUE, "write64mask", &mips3->impstate->write64mask[mode]); |
| 239 | static_generate_memory_accessor(mode, 1, FALSE, FALSE, "read8", &m_read8[mode]); |
| 240 | static_generate_memory_accessor(mode, 1, TRUE, FALSE, "write8", &m_write8[mode]); |
| 241 | static_generate_memory_accessor(mode, 2, FALSE, FALSE, "read16", &m_read16[mode]); |
| 242 | static_generate_memory_accessor(mode, 2, TRUE, FALSE, "write16", &m_write16[mode]); |
| 243 | static_generate_memory_accessor(mode, 4, FALSE, FALSE, "read32", &m_read32[mode]); |
| 244 | static_generate_memory_accessor(mode, 4, FALSE, TRUE, "read32mask", &m_read32mask[mode]); |
| 245 | static_generate_memory_accessor(mode, 4, TRUE, FALSE, "write32", &m_write32[mode]); |
| 246 | static_generate_memory_accessor(mode, 4, TRUE, TRUE, "write32mask", &m_write32mask[mode]); |
| 247 | static_generate_memory_accessor(mode, 8, FALSE, FALSE, "read64", &m_read64[mode]); |
| 248 | static_generate_memory_accessor(mode, 8, FALSE, TRUE, "read64mask", &m_read64mask[mode]); |
| 249 | static_generate_memory_accessor(mode, 8, TRUE, FALSE, "write64", &m_write64[mode]); |
| 250 | static_generate_memory_accessor(mode, 8, TRUE, TRUE, "write64mask", &m_write64mask[mode]); |
| 709 | 251 | } |
| 710 | 252 | } |
| 711 | 253 | catch (drcuml_block::abort_compilation &) |
| r30757 | r30758 | |
| 720 | 262 | given mode at the specified pc |
| 721 | 263 | -------------------------------------------------*/ |
| 722 | 264 | |
| 723 | | static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc) |
| 265 | void mips3_device::code_compile_block(UINT8 mode, offs_t pc) |
| 724 | 266 | { |
| 725 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 267 | drcuml_state *drcuml = m_drcuml; |
| 726 | 268 | compiler_state compiler = { 0 }; |
| 727 | 269 | const opcode_desc *seqhead, *seqlast; |
| 728 | 270 | const opcode_desc *desclist; |
| r30757 | r30758 | |
| 732 | 274 | g_profiler.start(PROFILER_DRC_COMPILE); |
| 733 | 275 | |
| 734 | 276 | /* get a description of this sequence */ |
| 735 | | desclist = mips3->impstate->drcfe->describe_code(pc); |
| 277 | desclist = m_drcfe->describe_code(pc); |
| 736 | 278 | if (LOG_UML || LOG_NATIVE) |
| 737 | 279 | log_opcode_desc(drcuml, desclist, 0); |
| 738 | 280 | |
| r30757 | r30758 | |
| 777 | 319 | else |
| 778 | 320 | { |
| 779 | 321 | UML_LABEL(block, seqhead->pc | 0x80000000); // label seqhead->pc | 0x80000000 |
| 780 | | UML_HASHJMP(block, mips3->impstate->mode, seqhead->pc, *mips3->impstate->nocode); |
| 322 | UML_HASHJMP(block, m_core->mode, seqhead->pc, *m_nocode); |
| 781 | 323 | // hashjmp <mode>,seqhead->pc,nocode |
| 782 | 324 | continue; |
| 783 | 325 | } |
| 784 | 326 | |
| 785 | 327 | /* validate this code block if we're not pointing into ROM */ |
| 786 | | if (mips3->program->get_write_ptr(seqhead->physpc) != NULL) |
| 787 | | generate_checksum_block(mips3, block, &compiler, seqhead, seqlast); |
| 328 | if (m_program->get_write_ptr(seqhead->physpc) != NULL) |
| 329 | generate_checksum_block(block, &compiler, seqhead, seqlast); |
| 788 | 330 | |
| 789 | 331 | /* label this instruction, if it may be jumped to locally */ |
| 790 | 332 | if (seqhead->flags & OPFLAG_IS_BRANCH_TARGET) |
| r30757 | r30758 | |
| 792 | 334 | |
| 793 | 335 | /* iterate over instructions in the sequence and compile them */ |
| 794 | 336 | for (curdesc = seqhead; curdesc != seqlast->next(); curdesc = curdesc->next()) |
| 795 | | generate_sequence_instruction(mips3, block, &compiler, curdesc); |
| 337 | generate_sequence_instruction(block, &compiler, curdesc); |
| 796 | 338 | |
| 797 | 339 | /* if we need to return to the start, do it */ |
| 798 | 340 | if (seqlast->flags & OPFLAG_RETURN_TO_START) |
| r30757 | r30758 | |
| 803 | 345 | nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; |
| 804 | 346 | |
| 805 | 347 | /* count off cycles and go there */ |
| 806 | | generate_update_cycles(mips3, block, &compiler, nextpc, TRUE); // <subtract cycles> |
| 348 | generate_update_cycles(block, &compiler, nextpc, TRUE); // <subtract cycles> |
| 807 | 349 | |
| 808 | 350 | /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */ |
| 809 | 351 | if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES) |
| 810 | | UML_HASHJMP(block, mem(&mips3->impstate->mode), nextpc, *mips3->impstate->nocode); |
| 352 | UML_HASHJMP(block, mem(&m_core->mode), nextpc, *m_nocode); |
| 811 | 353 | // hashjmp <mode>,nextpc,nocode |
| 812 | 354 | else if (seqlast->next() == NULL || seqlast->next()->pc != nextpc) |
| 813 | | UML_HASHJMP(block, mips3->impstate->mode, nextpc, *mips3->impstate->nocode); |
| 355 | UML_HASHJMP(block, m_core->mode, nextpc, *m_nocode); |
| 814 | 356 | // hashjmp <mode>,nextpc,nocode |
| 815 | 357 | } |
| 816 | 358 | |
| r30757 | r30758 | |
| 821 | 363 | } |
| 822 | 364 | catch (drcuml_block::abort_compilation &) |
| 823 | 365 | { |
| 824 | | code_flush_cache(mips3); |
| 366 | code_flush_cache(); |
| 825 | 367 | } |
| 826 | 368 | } |
| 827 | 369 | } |
| r30757 | r30758 | |
| 832 | 374 | C FUNCTION CALLBACKS |
| 833 | 375 | ***************************************************************************/ |
| 834 | 376 | |
| 377 | static void cfunc_mips3com_update_cycle_counting(void *param) |
| 378 | { |
| 379 | ((mips3_device *)param)->mips3com_update_cycle_counting(); |
| 380 | } |
| 381 | |
| 382 | static void cfunc_mips3com_asid_changed(void *param) |
| 383 | { |
| 384 | ((mips3_device *)param)->mips3com_asid_changed(); |
| 385 | } |
| 386 | |
| 387 | static void cfunc_mips3com_tlbr(void *param) |
| 388 | { |
| 389 | ((mips3_device *)param)->mips3com_tlbr(); |
| 390 | } |
| 391 | |
| 392 | static void cfunc_mips3com_tlbwi(void *param) |
| 393 | { |
| 394 | ((mips3_device *)param)->mips3com_tlbwi(); |
| 395 | } |
| 396 | |
| 397 | static void cfunc_mips3com_tlbwr(void *param) |
| 398 | { |
| 399 | ((mips3_device *)param)->mips3com_tlbwr(); |
| 400 | } |
| 401 | |
| 402 | static void cfunc_mips3com_tlbp(void *param) |
| 403 | { |
| 404 | ((mips3_device *)param)->mips3com_tlbp(); |
| 405 | } |
| 406 | |
| 835 | 407 | /*------------------------------------------------- |
| 836 | 408 | cfunc_get_cycles - compute the total number |
| 837 | 409 | of cycles executed so far |
| 838 | 410 | -------------------------------------------------*/ |
| 839 | 411 | |
| 412 | void mips3_device::func_get_cycles() |
| 413 | { |
| 414 | m_core->numcycles = total_cycles(); |
| 415 | } |
| 416 | |
| 840 | 417 | static void cfunc_get_cycles(void *param) |
| 841 | 418 | { |
| 842 | | mips3_state *mips3 = (mips3_state *)param; |
| 843 | | mips3->impstate->numcycles = mips3->device->total_cycles(); |
| 419 | ((mips3_device *)param)->func_get_cycles(); |
| 844 | 420 | } |
| 845 | 421 | |
| 846 | 422 | |
| r30757 | r30758 | |
| 849 | 425 | aren't interrupts |
| 850 | 426 | -------------------------------------------------*/ |
| 851 | 427 | |
| 428 | void mips3_device::func_printf_exception() |
| 429 | { |
| 430 | printf("Exception: EPC=%08X Cause=%08X BadVAddr=%08X Jmp=%08X\n", (UINT32)m_core->cpr[0][COP0_EPC], (UINT32)m_core->cpr[0][COP0_Cause], (UINT32)m_core->cpr[0][COP0_BadVAddr], m_core->pc); |
| 431 | func_printf_probe(); |
| 432 | } |
| 433 | |
| 852 | 434 | static void cfunc_printf_exception(void *param) |
| 853 | 435 | { |
| 854 | | mips3_state *mips3 = (mips3_state *)param; |
| 855 | | printf("Exception: EPC=%08X Cause=%08X BadVAddr=%08X Jmp=%08X\n", (UINT32)mips3->cpr[0][COP0_EPC], (UINT32)mips3->cpr[0][COP0_Cause], (UINT32)mips3->cpr[0][COP0_BadVAddr], mips3->pc); |
| 856 | | cfunc_printf_probe(mips3); |
| 436 | ((mips3_device *)param)->func_printf_exception(); |
| 857 | 437 | } |
| 858 | 438 | |
| 859 | | |
| 860 | 439 | /*------------------------------------------------- |
| 861 | 440 | cfunc_printf_debug - generic printf for |
| 862 | 441 | debugging |
| 863 | 442 | -------------------------------------------------*/ |
| 864 | 443 | |
| 444 | void mips3_device::func_printf_debug() |
| 445 | { |
| 446 | printf(m_core->format, m_core->arg0, m_core->arg1); |
| 447 | } |
| 448 | |
| 865 | 449 | static void cfunc_printf_debug(void *param) |
| 866 | 450 | { |
| 867 | | mips3_state *mips3 = (mips3_state *)param; |
| 868 | | printf(mips3->impstate->format, mips3->impstate->arg0, mips3->impstate->arg1); |
| 451 | ((mips3_device *)param)->func_printf_debug(); |
| 869 | 452 | } |
| 870 | 453 | |
| 871 | 454 | |
| r30757 | r30758 | |
| 874 | 457 | state and return |
| 875 | 458 | -------------------------------------------------*/ |
| 876 | 459 | |
| 877 | | static void cfunc_printf_probe(void *param) |
| 460 | void mips3_device::func_printf_probe() |
| 878 | 461 | { |
| 879 | | mips3_state *mips3 = (mips3_state *)param; |
| 880 | | |
| 881 | 462 | printf(" PC=%08X r1=%08X%08X r2=%08X%08X r3=%08X%08X\n", |
| 882 | | mips3->pc, |
| 883 | | (UINT32)(mips3->r[1] >> 32), (UINT32)mips3->r[1], |
| 884 | | (UINT32)(mips3->r[2] >> 32), (UINT32)mips3->r[2], |
| 885 | | (UINT32)(mips3->r[3] >> 32), (UINT32)mips3->r[3]); |
| 463 | m_core->pc, |
| 464 | (UINT32)(m_core->r[1] >> 32), (UINT32)m_core->r[1], |
| 465 | (UINT32)(m_core->r[2] >> 32), (UINT32)m_core->r[2], |
| 466 | (UINT32)(m_core->r[3] >> 32), (UINT32)m_core->r[3]); |
| 886 | 467 | printf(" r4=%08X%08X r5=%08X%08X r6=%08X%08X r7=%08X%08X\n", |
| 887 | | (UINT32)(mips3->r[4] >> 32), (UINT32)mips3->r[4], |
| 888 | | (UINT32)(mips3->r[5] >> 32), (UINT32)mips3->r[5], |
| 889 | | (UINT32)(mips3->r[6] >> 32), (UINT32)mips3->r[6], |
| 890 | | (UINT32)(mips3->r[7] >> 32), (UINT32)mips3->r[7]); |
| 468 | (UINT32)(m_core->r[4] >> 32), (UINT32)m_core->r[4], |
| 469 | (UINT32)(m_core->r[5] >> 32), (UINT32)m_core->r[5], |
| 470 | (UINT32)(m_core->r[6] >> 32), (UINT32)m_core->r[6], |
| 471 | (UINT32)(m_core->r[7] >> 32), (UINT32)m_core->r[7]); |
| 891 | 472 | printf(" r8=%08X%08X r9=%08X%08X r10=%08X%08X r11=%08X%08X\n", |
| 892 | | (UINT32)(mips3->r[8] >> 32), (UINT32)mips3->r[8], |
| 893 | | (UINT32)(mips3->r[9] >> 32), (UINT32)mips3->r[9], |
| 894 | | (UINT32)(mips3->r[10] >> 32), (UINT32)mips3->r[10], |
| 895 | | (UINT32)(mips3->r[11] >> 32), (UINT32)mips3->r[11]); |
| 473 | (UINT32)(m_core->r[8] >> 32), (UINT32)m_core->r[8], |
| 474 | (UINT32)(m_core->r[9] >> 32), (UINT32)m_core->r[9], |
| 475 | (UINT32)(m_core->r[10] >> 32), (UINT32)m_core->r[10], |
| 476 | (UINT32)(m_core->r[11] >> 32), (UINT32)m_core->r[11]); |
| 896 | 477 | printf("r12=%08X%08X r13=%08X%08X r14=%08X%08X r15=%08X%08X\n", |
| 897 | | (UINT32)(mips3->r[12] >> 32), (UINT32)mips3->r[12], |
| 898 | | (UINT32)(mips3->r[13] >> 32), (UINT32)mips3->r[13], |
| 899 | | (UINT32)(mips3->r[14] >> 32), (UINT32)mips3->r[14], |
| 900 | | (UINT32)(mips3->r[15] >> 32), (UINT32)mips3->r[15]); |
| 478 | (UINT32)(m_core->r[12] >> 32), (UINT32)m_core->r[12], |
| 479 | (UINT32)(m_core->r[13] >> 32), (UINT32)m_core->r[13], |
| 480 | (UINT32)(m_core->r[14] >> 32), (UINT32)m_core->r[14], |
| 481 | (UINT32)(m_core->r[15] >> 32), (UINT32)m_core->r[15]); |
| 901 | 482 | printf("r16=%08X%08X r17=%08X%08X r18=%08X%08X r19=%08X%08X\n", |
| 902 | | (UINT32)(mips3->r[16] >> 32), (UINT32)mips3->r[16], |
| 903 | | (UINT32)(mips3->r[17] >> 32), (UINT32)mips3->r[17], |
| 904 | | (UINT32)(mips3->r[18] >> 32), (UINT32)mips3->r[18], |
| 905 | | (UINT32)(mips3->r[19] >> 32), (UINT32)mips3->r[19]); |
| 483 | (UINT32)(m_core->r[16] >> 32), (UINT32)m_core->r[16], |
| 484 | (UINT32)(m_core->r[17] >> 32), (UINT32)m_core->r[17], |
| 485 | (UINT32)(m_core->r[18] >> 32), (UINT32)m_core->r[18], |
| 486 | (UINT32)(m_core->r[19] >> 32), (UINT32)m_core->r[19]); |
| 906 | 487 | printf("r20=%08X%08X r21=%08X%08X r22=%08X%08X r23=%08X%08X\n", |
| 907 | | (UINT32)(mips3->r[20] >> 32), (UINT32)mips3->r[20], |
| 908 | | (UINT32)(mips3->r[21] >> 32), (UINT32)mips3->r[21], |
| 909 | | (UINT32)(mips3->r[22] >> 32), (UINT32)mips3->r[22], |
| 910 | | (UINT32)(mips3->r[23] >> 32), (UINT32)mips3->r[23]); |
| 488 | (UINT32)(m_core->r[20] >> 32), (UINT32)m_core->r[20], |
| 489 | (UINT32)(m_core->r[21] >> 32), (UINT32)m_core->r[21], |
| 490 | (UINT32)(m_core->r[22] >> 32), (UINT32)m_core->r[22], |
| 491 | (UINT32)(m_core->r[23] >> 32), (UINT32)m_core->r[23]); |
| 911 | 492 | printf("r24=%08X%08X r25=%08X%08X r26=%08X%08X r27=%08X%08X\n", |
| 912 | | (UINT32)(mips3->r[24] >> 32), (UINT32)mips3->r[24], |
| 913 | | (UINT32)(mips3->r[25] >> 32), (UINT32)mips3->r[25], |
| 914 | | (UINT32)(mips3->r[26] >> 32), (UINT32)mips3->r[26], |
| 915 | | (UINT32)(mips3->r[27] >> 32), (UINT32)mips3->r[27]); |
| 493 | (UINT32)(m_core->r[24] >> 32), (UINT32)m_core->r[24], |
| 494 | (UINT32)(m_core->r[25] >> 32), (UINT32)m_core->r[25], |
| 495 | (UINT32)(m_core->r[26] >> 32), (UINT32)m_core->r[26], |
| 496 | (UINT32)(m_core->r[27] >> 32), (UINT32)m_core->r[27]); |
| 916 | 497 | printf("r28=%08X%08X r29=%08X%08X r30=%08X%08X r31=%08X%08X\n", |
| 917 | | (UINT32)(mips3->r[28] >> 32), (UINT32)mips3->r[28], |
| 918 | | (UINT32)(mips3->r[29] >> 32), (UINT32)mips3->r[29], |
| 919 | | (UINT32)(mips3->r[30] >> 32), (UINT32)mips3->r[30], |
| 920 | | (UINT32)(mips3->r[31] >> 32), (UINT32)mips3->r[31]); |
| 498 | (UINT32)(m_core->r[28] >> 32), (UINT32)m_core->r[28], |
| 499 | (UINT32)(m_core->r[29] >> 32), (UINT32)m_core->r[29], |
| 500 | (UINT32)(m_core->r[30] >> 32), (UINT32)m_core->r[30], |
| 501 | (UINT32)(m_core->r[31] >> 32), (UINT32)m_core->r[31]); |
| 921 | 502 | printf(" hi=%08X%08X lo=%08X%08X\n", |
| 922 | | (UINT32)(mips3->r[REG_HI] >> 32), (UINT32)mips3->r[REG_HI], |
| 923 | | (UINT32)(mips3->r[REG_LO] >> 32), (UINT32)mips3->r[REG_LO]); |
| 503 | (UINT32)(m_core->r[REG_HI] >> 32), (UINT32)m_core->r[REG_HI], |
| 504 | (UINT32)(m_core->r[REG_LO] >> 32), (UINT32)m_core->r[REG_LO]); |
| 924 | 505 | } |
| 925 | 506 | |
| 507 | static void cfunc_printf_probe(void *param) |
| 508 | { |
| 509 | ((mips3_device *)param)->func_printf_probe(); |
| 510 | } |
| 926 | 511 | |
| 927 | 512 | /*------------------------------------------------- |
| 928 | 513 | cfunc_unimplemented - handler for |
| 929 | 514 | unimplemented opcdes |
| 930 | 515 | -------------------------------------------------*/ |
| 931 | 516 | |
| 517 | void mips3_device::func_unimplemented() |
| 518 | { |
| 519 | UINT32 opcode = m_core->arg0; |
| 520 | fatalerror("PC=%08X: Unimplemented op %08X (%02X,%02X)\n", m_core->pc, opcode, opcode >> 26, opcode & 0x3f); |
| 521 | } |
| 522 | |
| 932 | 523 | static void cfunc_unimplemented(void *param) |
| 933 | 524 | { |
| 934 | | mips3_state *mips3 = (mips3_state *)param; |
| 935 | | UINT32 opcode = mips3->impstate->arg0; |
| 936 | | fatalerror("PC=%08X: Unimplemented op %08X (%02X,%02X)\n", mips3->pc, opcode, opcode >> 26, opcode & 0x3f); |
| 525 | ((mips3_device *)param)->func_unimplemented(); |
| 937 | 526 | } |
| 938 | 527 | |
| 939 | 528 | |
| 940 | | |
| 941 | 529 | /*************************************************************************** |
| 942 | 530 | STATIC CODEGEN |
| 943 | 531 | ***************************************************************************/ |
| r30757 | r30758 | |
| 947 | 535 | static entry point |
| 948 | 536 | -------------------------------------------------*/ |
| 949 | 537 | |
| 950 | | static void static_generate_entry_point(mips3_state *mips3) |
| 538 | void mips3_device::static_generate_entry_point() |
| 951 | 539 | { |
| 952 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 540 | drcuml_state *drcuml = m_drcuml; |
| 953 | 541 | code_label skip = 1; |
| 954 | 542 | drcuml_block *block; |
| 955 | 543 | |
| 956 | 544 | block = drcuml->begin_block(20); |
| 957 | 545 | |
| 958 | 546 | /* forward references */ |
| 959 | | alloc_handle(drcuml, &mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT], "interrupt_norecover"); |
| 960 | | alloc_handle(drcuml, &mips3->impstate->nocode, "nocode"); |
| 547 | alloc_handle(drcuml, &m_exception_norecover[EXCEPTION_INTERRUPT], "interrupt_norecover"); |
| 548 | alloc_handle(drcuml, &m_nocode, "nocode"); |
| 961 | 549 | |
| 962 | | alloc_handle(drcuml, &mips3->impstate->entry, "entry"); |
| 963 | | UML_HANDLE(block, *mips3->impstate->entry); // handle entry |
| 550 | alloc_handle(drcuml, &m_entry, "entry"); |
| 551 | UML_HANDLE(block, *m_entry); // handle entry |
| 964 | 552 | |
| 965 | 553 | /* reset the FPU mode */ |
| 966 | 554 | UML_AND(block, I0, CCR132(31), 3); // and i0,ccr1[31],3 |
| 967 | | UML_LOAD(block, I0, &mips3->impstate->fpmode[0], I0, SIZE_BYTE, SCALE_x1);// load i0,fpmode,i0,byte |
| 555 | UML_LOAD(block, I0, &m_fpmode[0], I0, SIZE_BYTE, SCALE_x1);// load i0,fpmode,i0,byte |
| 968 | 556 | UML_SETFMOD(block, I0); // setfmod i0 |
| 969 | 557 | |
| 970 | 558 | /* load fast integer registers */ |
| 971 | | load_fast_iregs(mips3, block); |
| 559 | load_fast_iregs(block); |
| 972 | 560 | |
| 973 | 561 | /* check for interrupts */ |
| 974 | 562 | UML_AND(block, I0, CPR032(COP0_Cause), CPR032(COP0_Status)); // and i0,[Cause],[Status] |
| r30757 | r30758 | |
| 978 | 566 | UML_JMPc(block, COND_Z, skip); // jmp skip,Z |
| 979 | 567 | UML_TEST(block, CPR032(COP0_Status), SR_EXL | SR_ERL); // test [Status],SR_EXL | SR_ERL |
| 980 | 568 | UML_JMPc(block, COND_NZ, skip); // jmp skip,NZ |
| 981 | | UML_MOV(block, I0, mem(&mips3->pc)); // mov i0,pc |
| 569 | UML_MOV(block, I0, mem(&m_core->pc)); // mov i0,pc |
| 982 | 570 | UML_MOV(block, I1, 0); // mov i1,0 |
| 983 | | UML_CALLH(block, *mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]); // callh exception_norecover |
| 571 | UML_CALLH(block, *m_exception_norecover[EXCEPTION_INTERRUPT]); // callh exception_norecover |
| 984 | 572 | UML_LABEL(block, skip); // skip: |
| 985 | 573 | |
| 986 | 574 | /* generate a hash jump via the current mode and PC */ |
| 987 | | UML_HASHJMP(block, mem(&mips3->impstate->mode), mem(&mips3->pc), *mips3->impstate->nocode); |
| 575 | UML_HASHJMP(block, mem(&m_core->mode), mem(&m_core->pc), *m_nocode); |
| 988 | 576 | // hashjmp <mode>,<pc>,nocode |
| 989 | 577 | block->end(); |
| 990 | 578 | } |
| r30757 | r30758 | |
| 995 | 583 | exception handler for "out of code" |
| 996 | 584 | -------------------------------------------------*/ |
| 997 | 585 | |
| 998 | | static void static_generate_nocode_handler(mips3_state *mips3) |
| 586 | void mips3_device::static_generate_nocode_handler() |
| 999 | 587 | { |
| 1000 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 588 | drcuml_state *drcuml = m_drcuml; |
| 1001 | 589 | drcuml_block *block; |
| 1002 | 590 | |
| 1003 | 591 | /* begin generating */ |
| 1004 | 592 | block = drcuml->begin_block(10); |
| 1005 | 593 | |
| 1006 | 594 | /* generate a hash jump via the current mode and PC */ |
| 1007 | | alloc_handle(drcuml, &mips3->impstate->nocode, "nocode"); |
| 1008 | | UML_HANDLE(block, *mips3->impstate->nocode); // handle nocode |
| 595 | alloc_handle(drcuml, &m_nocode, "nocode"); |
| 596 | UML_HANDLE(block, *m_nocode); // handle nocode |
| 1009 | 597 | UML_GETEXP(block, I0); // getexp i0 |
| 1010 | | UML_MOV(block, mem(&mips3->pc), I0); // mov [pc],i0 |
| 1011 | | save_fast_iregs(mips3, block); |
| 598 | UML_MOV(block, mem(&m_core->pc), I0); // mov [pc],i0 |
| 599 | save_fast_iregs(block); |
| 1012 | 600 | UML_EXIT(block, EXECUTE_MISSING_CODE); // exit EXECUTE_MISSING_CODE |
| 1013 | 601 | |
| 1014 | 602 | block->end(); |
| r30757 | r30758 | |
| 1020 | 608 | out of cycles exception handler |
| 1021 | 609 | -------------------------------------------------*/ |
| 1022 | 610 | |
| 1023 | | static void static_generate_out_of_cycles(mips3_state *mips3) |
| 611 | void mips3_device::static_generate_out_of_cycles() |
| 1024 | 612 | { |
| 1025 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 613 | drcuml_state *drcuml = m_drcuml; |
| 1026 | 614 | drcuml_block *block; |
| 1027 | 615 | |
| 1028 | 616 | /* begin generating */ |
| 1029 | 617 | block = drcuml->begin_block(10); |
| 1030 | 618 | |
| 1031 | 619 | /* generate a hash jump via the current mode and PC */ |
| 1032 | | alloc_handle(drcuml, &mips3->impstate->out_of_cycles, "out_of_cycles"); |
| 1033 | | UML_HANDLE(block, *mips3->impstate->out_of_cycles); // handle out_of_cycles |
| 620 | alloc_handle(drcuml, &m_out_of_cycles, "out_of_cycles"); |
| 621 | UML_HANDLE(block, *m_out_of_cycles); // handle out_of_cycles |
| 1034 | 622 | UML_GETEXP(block, I0); // getexp i0 |
| 1035 | | UML_MOV(block, mem(&mips3->pc), I0); // mov <pc>,i0 |
| 1036 | | save_fast_iregs(mips3, block); |
| 623 | UML_MOV(block, mem(&m_core->pc), I0); // mov <pc>,i0 |
| 624 | save_fast_iregs(block); |
| 1037 | 625 | UML_EXIT(block, EXECUTE_OUT_OF_CYCLES); // exit EXECUTE_OUT_OF_CYCLES |
| 1038 | 626 | |
| 1039 | 627 | block->end(); |
| r30757 | r30758 | |
| 1045 | 633 | TLB mismatch handler |
| 1046 | 634 | -------------------------------------------------*/ |
| 1047 | 635 | |
| 1048 | | static void static_generate_tlb_mismatch(mips3_state *mips3) |
| 636 | void mips3_device::static_generate_tlb_mismatch() |
| 1049 | 637 | { |
| 1050 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 638 | drcuml_state *drcuml = m_drcuml; |
| 1051 | 639 | drcuml_block *block; |
| 1052 | 640 | |
| 1053 | 641 | /* forward references */ |
| 1054 | | alloc_handle(drcuml, &mips3->impstate->exception[EXCEPTION_TLBLOAD], "exception_tlbload"); |
| 1055 | | alloc_handle(drcuml, &mips3->impstate->exception[EXCEPTION_TLBLOAD_FILL], "exception_tlbload_fill"); |
| 642 | alloc_handle(drcuml, &m_exception[EXCEPTION_TLBLOAD], "exception_tlbload"); |
| 643 | alloc_handle(drcuml, &m_exception[EXCEPTION_TLBLOAD_FILL], "exception_tlbload_fill"); |
| 1056 | 644 | |
| 1057 | 645 | /* begin generating */ |
| 1058 | 646 | block = drcuml->begin_block(20); |
| 1059 | 647 | |
| 1060 | 648 | /* generate a hash jump via the current mode and PC */ |
| 1061 | | alloc_handle(drcuml, &mips3->impstate->tlb_mismatch, "tlb_mismatch"); |
| 1062 | | UML_HANDLE(block, *mips3->impstate->tlb_mismatch); // handle tlb_mismatch |
| 649 | alloc_handle(drcuml, &m_tlb_mismatch, "tlb_mismatch"); |
| 650 | UML_HANDLE(block, *m_tlb_mismatch); // handle tlb_mismatch |
| 1063 | 651 | UML_RECOVER(block, I0, MAPVAR_PC); // recover i0,PC |
| 1064 | | UML_MOV(block, mem(&mips3->pc), I0); // mov <pc>,i0 |
| 652 | UML_MOV(block, mem(&m_core->pc), I0); // mov <pc>,i0 |
| 1065 | 653 | UML_SHR(block, I1, I0, 12); // shr i1,i0,12 |
| 1066 | | UML_LOAD(block, I1, (void *)vtlb_table(mips3->vtlb), I1, SIZE_DWORD, SCALE_x4);// load i1,[vtlb_table],i1,dword |
| 654 | UML_LOAD(block, I1, (void *)vtlb_table(m_vtlb), I1, SIZE_DWORD, SCALE_x4);// load i1,[vtlb_table],i1,dword |
| 1067 | 655 | if (PRINTF_MMU) |
| 1068 | 656 | { |
| 1069 | 657 | static const char text[] = "TLB mismatch @ %08X (ent=%08X)\n"; |
| 1070 | | UML_MOV(block, mem(&mips3->impstate->format), (FPTR)text); // mov [format],text |
| 1071 | | UML_MOV(block, mem(&mips3->impstate->arg0), I0); // mov [arg0],i0 |
| 1072 | | UML_MOV(block, mem(&mips3->impstate->arg1), I1); // mov [arg1],i1 |
| 1073 | | UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug |
| 658 | UML_MOV(block, mem(&m_core->format), (FPTR)text); // mov [format],text |
| 659 | UML_MOV(block, mem(&m_core->arg0), I0); // mov [arg0],i0 |
| 660 | UML_MOV(block, mem(&m_core->arg1), I1); // mov [arg1],i1 |
| 661 | UML_CALLC(block, cfunc_printf_debug, this); // callc printf_debug |
| 1074 | 662 | } |
| 1075 | 663 | UML_TEST(block, I1, VTLB_FETCH_ALLOWED); // test i1,VTLB_FETCH_ALLOWED |
| 1076 | 664 | UML_JMPc(block, COND_NZ, 1); // jmp 1,nz |
| 1077 | 665 | UML_TEST(block, I1, VTLB_FLAG_FIXED); // test i1,VTLB_FLAG_FIXED |
| 1078 | | UML_EXHc(block, COND_NZ, *mips3->impstate->exception[EXCEPTION_TLBLOAD], I0); // exh exception[TLBLOAD],i0,nz |
| 1079 | | UML_EXH(block, *mips3->impstate->exception[EXCEPTION_TLBLOAD_FILL], I0); // exh exception[TLBLOAD_FILL],i0 |
| 666 | UML_EXHc(block, COND_NZ, *m_exception[EXCEPTION_TLBLOAD], I0); // exh exception[TLBLOAD],i0,nz |
| 667 | UML_EXH(block, *m_exception[EXCEPTION_TLBLOAD_FILL], I0); // exh exception[TLBLOAD_FILL],i0 |
| 1080 | 668 | UML_LABEL(block, 1); // 1: |
| 1081 | | save_fast_iregs(mips3, block); |
| 669 | save_fast_iregs(block); |
| 1082 | 670 | |
| 1083 | 671 | // the saved PC may be set 1 instruction back with the low bit set to indicate |
| 1084 | 672 | // a delay slot; in this path we want the original instruction address, so recover it |
| 1085 | | UML_ADD(block, I0, mem(&mips3->pc), 3); // add i0,<pc>,3 |
| 1086 | | UML_AND(block, mem(&mips3->pc), I0, ~3); // and <pc>,i0,~3 |
| 673 | UML_ADD(block, I0, mem(&m_core->pc), 3); // add i0,<pc>,3 |
| 674 | UML_AND(block, mem(&m_core->pc), I0, ~3); // and <pc>,i0,~3 |
| 1087 | 675 | UML_EXIT(block, EXECUTE_MISSING_CODE); // exit EXECUTE_MISSING_CODE |
| 1088 | 676 | |
| 1089 | 677 | block->end(); |
| r30757 | r30758 | |
| 1095 | 683 | exception handler |
| 1096 | 684 | -------------------------------------------------*/ |
| 1097 | 685 | |
| 1098 | | static void static_generate_exception(mips3_state *mips3, UINT8 exception, int recover, const char *name) |
| 686 | void mips3_device::static_generate_exception(UINT8 exception, int recover, const char *name) |
| 1099 | 687 | { |
| 1100 | | code_handle *&exception_handle = recover ? mips3->impstate->exception[exception] : mips3->impstate->exception_norecover[exception]; |
| 1101 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 688 | code_handle *&exception_handle = recover ? m_exception[exception] : m_exception_norecover[exception]; |
| 689 | drcuml_state *drcuml = m_drcuml; |
| 1102 | 690 | UINT32 offset = 0x180; |
| 1103 | 691 | code_label next = 1; |
| 1104 | 692 | code_label skip = 2; |
| r30757 | r30758 | |
| 1163 | 751 | /* set EXL in the SR */ |
| 1164 | 752 | UML_OR(block, I0, CPR032(COP0_Status), SR_EXL); // or i0,[Status],SR_EXL |
| 1165 | 753 | UML_MOV(block, CPR032(COP0_Status), I0); // mov [Status],i0 |
| 1166 | | generate_update_mode(mips3, block); |
| 754 | generate_update_mode(block); |
| 1167 | 755 | |
| 1168 | 756 | /* optionally print exceptions */ |
| 1169 | 757 | if ((PRINTF_EXCEPTIONS && exception != EXCEPTION_INTERRUPT && exception != EXCEPTION_SYSCALL) || |
| 1170 | 758 | (PRINTF_MMU && (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE))) |
| 1171 | 759 | { |
| 1172 | | UML_CALLC(block, cfunc_printf_exception, mips3); // callc cfunc_printf_exception,NULL |
| 760 | UML_CALLC(block, cfunc_printf_exception, this); // callc cfunc_printf_exception,NULL |
| 1173 | 761 | } |
| 1174 | 762 | |
| 1175 | 763 | /* choose our target PC */ |
| r30757 | r30758 | |
| 1180 | 768 | UML_LABEL(block, skip); // <skip>: |
| 1181 | 769 | |
| 1182 | 770 | /* adjust cycles */ |
| 1183 | | UML_SUB(block, mem(&mips3->icount), mem(&mips3->icount), I1); // sub icount,icount,cycles,S |
| 1184 | | UML_EXHc(block, COND_S, *mips3->impstate->out_of_cycles, I0); // exh out_of_cycles,i0 |
| 771 | UML_SUB(block, mem(&m_core->icount), mem(&m_core->icount), I1); // sub icount,icount,cycles,S |
| 772 | UML_EXHc(block, COND_S, *m_out_of_cycles, I0); // exh out_of_cycles,i0 |
| 1185 | 773 | |
| 1186 | | UML_HASHJMP(block, mem(&mips3->impstate->mode), I0, *mips3->impstate->nocode);// hashjmp <mode>,i0,nocode |
| 774 | UML_HASHJMP(block, mem(&m_core->mode), I0, *m_nocode);// hashjmp <mode>,i0,nocode |
| 1187 | 775 | |
| 1188 | 776 | block->end(); |
| 1189 | 777 | } |
| r30757 | r30758 | |
| 1193 | 781 | static_generate_memory_accessor |
| 1194 | 782 | ------------------------------------------------------------------*/ |
| 1195 | 783 | |
| 1196 | | static void static_generate_memory_accessor(mips3_state *mips3, int mode, int size, int iswrite, int ismasked, const char *name, code_handle **handleptr) |
| 784 | void mips3_device::static_generate_memory_accessor(int mode, int size, int iswrite, int ismasked, const char *name, code_handle **handleptr) |
| 1197 | 785 | { |
| 1198 | 786 | /* on entry, address is in I0; data for writes is in I1; mask for accesses is in I2 */ |
| 1199 | 787 | /* on exit, read result is in I0 */ |
| 1200 | 788 | /* routine trashes I0-I3 */ |
| 1201 | | code_handle &exception_tlb = *mips3->impstate->exception[iswrite ? EXCEPTION_TLBSTORE : EXCEPTION_TLBLOAD]; |
| 1202 | | code_handle &exception_tlbfill = *mips3->impstate->exception[iswrite ? EXCEPTION_TLBSTORE_FILL : EXCEPTION_TLBLOAD_FILL]; |
| 1203 | | code_handle &exception_addrerr = *mips3->impstate->exception[iswrite ? EXCEPTION_ADDRSTORE : EXCEPTION_ADDRLOAD]; |
| 1204 | | drcuml_state *drcuml = mips3->impstate->drcuml; |
| 789 | code_handle &exception_tlb = *m_exception[iswrite ? EXCEPTION_TLBSTORE : EXCEPTION_TLBLOAD]; |
| 790 | code_handle &exception_tlbfill = *m_exception[iswrite ? EXCEPTION_TLBSTORE_FILL : EXCEPTION_TLBLOAD_FILL]; |
| 791 | code_handle &exception_addrerr = *m_exception[iswrite ? EXCEPTION_ADDRSTORE : EXCEPTION_ADDRLOAD]; |
| 792 | drcuml_state *drcuml = m_drcuml; |
| 1205 | 793 | drcuml_block *block; |
| 1206 | 794 | int tlbmiss = 0; |
| 1207 | 795 | int label = 1; |
| r30757 | r30758 | |
| 1235 | 823 | |
| 1236 | 824 | /* general case: assume paging and perform a translation */ |
| 1237 | 825 | UML_SHR(block, I3, I0, 12); // shr i3,i0,12 |
| 1238 | | UML_LOAD(block, I3, (void *)vtlb_table(mips3->vtlb), I3, SIZE_DWORD, SCALE_x4);// load i3,[vtlb_table],i3,dword |
| 826 | UML_LOAD(block, I3, (void *)vtlb_table(m_vtlb), I3, SIZE_DWORD, SCALE_x4);// load i3,[vtlb_table],i3,dword |
| 1239 | 827 | UML_TEST(block, I3, iswrite ? VTLB_WRITE_ALLOWED : VTLB_READ_ALLOWED);// test i3,iswrite ? VTLB_WRITE_ALLOWED : VTLB_READ_ALLOWED |
| 1240 | 828 | UML_JMPc(block, COND_Z, tlbmiss = label++); // jmp tlbmiss,z |
| 1241 | 829 | UML_ROLINS(block, I0, I3, 0, 0xfffff000); // rolins i0,i3,0,0xfffff000 |
| 1242 | 830 | |
| 1243 | | if ((mips3->device->machine().debug_flags & DEBUG_FLAG_ENABLED) == 0) |
| 831 | if ((machine().debug_flags & DEBUG_FLAG_ENABLED) == 0) |
| 1244 | 832 | for (ramnum = 0; ramnum < MIPS3_MAX_FASTRAM; ramnum++) |
| 1245 | | if (mips3->impstate->fastram[ramnum].base != NULL && (!iswrite || !mips3->impstate->fastram[ramnum].readonly)) |
| 833 | if (m_fastram[ramnum].base != NULL && (!iswrite || !m_fastram[ramnum].readonly)) |
| 1246 | 834 | { |
| 1247 | | void *fastbase = (UINT8 *)mips3->impstate->fastram[ramnum].base - mips3->impstate->fastram[ramnum].start; |
| 835 | void *fastbase = (UINT8 *)m_fastram[ramnum].base - m_fastram[ramnum].start; |
| 1248 | 836 | UINT32 skip = label++; |
| 1249 | | if (mips3->impstate->fastram[ramnum].end != 0xffffffff) |
| 837 | if (m_fastram[ramnum].end != 0xffffffff) |
| 1250 | 838 | { |
| 1251 | | UML_CMP(block, I0, mips3->impstate->fastram[ramnum].end); // cmp i0,end |
| 839 | UML_CMP(block, I0, m_fastram[ramnum].end); // cmp i0,end |
| 1252 | 840 | UML_JMPc(block, COND_A, skip); // ja skip |
| 1253 | 841 | } |
| 1254 | | if (mips3->impstate->fastram[ramnum].start != 0x00000000) |
| 842 | if (m_fastram[ramnum].start != 0x00000000) |
| 1255 | 843 | { |
| 1256 | | UML_CMP(block, I0, mips3->impstate->fastram[ramnum].start);// cmp i0,fastram_start |
| 844 | UML_CMP(block, I0, m_fastram[ramnum].start);// cmp i0,fastram_start |
| 1257 | 845 | UML_JMPc(block, COND_B, skip); // jb skip |
| 1258 | 846 | } |
| 1259 | 847 | |
| r30757 | r30758 | |
| 1261 | 849 | { |
| 1262 | 850 | if (size == 1) |
| 1263 | 851 | { |
| 1264 | | UML_XOR(block, I0, I0, mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0)); |
| 852 | UML_XOR(block, I0, I0, m_bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0)); |
| 1265 | 853 | // xor i0,i0,bytexor |
| 1266 | 854 | UML_LOAD(block, I0, fastbase, I0, SIZE_BYTE, SCALE_x1); // load i0,fastbase,i0,byte |
| 1267 | 855 | } |
| 1268 | 856 | else if (size == 2) |
| 1269 | 857 | { |
| 1270 | | UML_XOR(block, I0, I0, mips3->bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)); |
| 858 | UML_XOR(block, I0, I0, m_bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)); |
| 1271 | 859 | // xor i0,i0,wordxor |
| 1272 | 860 | UML_LOAD(block, I0, fastbase, I0, SIZE_WORD, SCALE_x1); // load i0,fastbase,i0,word_x1 |
| 1273 | 861 | } |
| r30757 | r30758 | |
| 1278 | 866 | else if (size == 8) |
| 1279 | 867 | { |
| 1280 | 868 | UML_DLOAD(block, I0, fastbase, I0, SIZE_QWORD, SCALE_x1); // dload i0,fastbase,i0,qword_x1 |
| 1281 | | UML_DROR(block, I0, I0, 32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 869 | UML_DROR(block, I0, I0, 32 * (m_bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 1282 | 870 | // dror i0,i0,32*bytexor |
| 1283 | 871 | } |
| 1284 | 872 | UML_RET(block); // ret |
| r30757 | r30758 | |
| 1287 | 875 | { |
| 1288 | 876 | if (size == 1) |
| 1289 | 877 | { |
| 1290 | | UML_XOR(block, I0, I0, mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0)); |
| 878 | UML_XOR(block, I0, I0, m_bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0)); |
| 1291 | 879 | // xor i0,i0,bytexor |
| 1292 | 880 | UML_STORE(block, fastbase, I0, I1, SIZE_BYTE, SCALE_x1);// store fastbase,i0,i1,byte |
| 1293 | 881 | } |
| 1294 | 882 | else if (size == 2) |
| 1295 | 883 | { |
| 1296 | | UML_XOR(block, I0, I0, mips3->bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)); |
| 884 | UML_XOR(block, I0, I0, m_bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)); |
| 1297 | 885 | // xor i0,i0,wordxor |
| 1298 | 886 | UML_STORE(block, fastbase, I0, I1, SIZE_WORD, SCALE_x1);// store fastbase,i0,i1,word_x1 |
| 1299 | 887 | } |
| r30757 | r30758 | |
| 1310 | 898 | } |
| 1311 | 899 | else if (size == 8) |
| 1312 | 900 | { |
| 1313 | | UML_DROR(block, I1, I1, 32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 901 | UML_DROR(block, I1, I1, 32 * (m_bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 1314 | 902 | // dror i1,i1,32*bytexor |
| 1315 | 903 | if (ismasked) |
| 1316 | 904 | { |
| 1317 | | UML_DROR(block, I2, I2, 32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 905 | UML_DROR(block, I2, I2, 32 * (m_bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); |
| 1318 | 906 | // dror i2,i2,32*bytexor |
| 1319 | 907 | UML_DLOAD(block, I3, fastbase, I0, SIZE_QWORD, SCALE_x1); // dload i3,fastbase,i0,qword_x1 |
| 1320 | 908 | UML_DROLINS(block, I3, I1, 0, I2); // drolins i3,i1,0,i2 |
| r30757 | r30758 | |
| 1387 | 975 | if (iswrite) |
| 1388 | 976 | { |
| 1389 | 977 | UML_TEST(block, I3, VTLB_READ_ALLOWED); // test i3,VTLB_READ_ALLOWED |
| 1390 | | UML_EXHc(block, COND_NZ, *mips3->impstate->exception[EXCEPTION_TLBMOD], I0); |
| 978 | UML_EXHc(block, COND_NZ, *m_exception[EXCEPTION_TLBMOD], I0); |
| 1391 | 979 | // exh tlbmod,i0,nz |
| 1392 | 980 | } |
| 1393 | 981 | UML_TEST(block, I3, VTLB_FLAG_FIXED); // test i3,VTLB_FLAG_FIXED |
| r30757 | r30758 | |
| 1409 | 997 | on a new SR (in i0); trashes i2 |
| 1410 | 998 | -------------------------------------------------*/ |
| 1411 | 999 | |
| 1412 | | static void generate_update_mode(mips3_state *mips3, drcuml_block *block) |
| 1000 | void mips3_device::generate_update_mode(drcuml_block *block) |
| 1413 | 1001 | { |
| 1414 | 1002 | UML_ROLAND(block, I2, I0, 32-2, 0x06); // roland i2,i0,32-2,0x06 |
| 1415 | 1003 | UML_TEST(block, I0, SR_EXL | SR_ERL); // test i0,SR_EXL | SR_ERL |
| 1416 | 1004 | UML_MOVc(block, COND_NZ, I2, 0); // mov i2,0,nz |
| 1417 | 1005 | UML_ROLINS(block, I2, I0, 32-26, 0x01); // rolins i2,i0,32-26,0x01 |
| 1418 | | UML_MOV(block, mem(&mips3->impstate->mode), I2); // mov [mode],i2 |
| 1006 | UML_MOV(block, mem(&m_core->mode), I2); // mov [mode],i2 |
| 1419 | 1007 | } |
| 1420 | 1008 | |
| 1421 | 1009 | |
| r30757 | r30758 | |
| 1425 | 1013 | an exception if out |
| 1426 | 1014 | -------------------------------------------------*/ |
| 1427 | 1015 | |
| 1428 | | static void generate_update_cycles(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, parameter param, int allow_exception) |
| 1016 | void mips3_device::generate_update_cycles(drcuml_block *block, compiler_state *compiler, parameter param, int allow_exception) |
| 1429 | 1017 | { |
| 1430 | 1018 | /* check software interrupts if pending */ |
| 1431 | 1019 | if (compiler->checksoftints) |
| r30757 | r30758 | |
| 1438 | 1026 | UML_JMPc(block, COND_Z, skip = compiler->labelnum++); // jmp skip,Z |
| 1439 | 1027 | UML_MOV(block, I0, param); // mov i0,nextpc |
| 1440 | 1028 | UML_MOV(block, I1, compiler->cycles); // mov i1,cycles |
| 1441 | | UML_CALLH(block, *mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover |
| 1029 | UML_CALLH(block, *m_exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover |
| 1442 | 1030 | UML_LABEL(block, skip); // skip: |
| 1443 | 1031 | } |
| 1444 | 1032 | |
| r30757 | r30758 | |
| 1457 | 1045 | UML_JMPc(block, COND_NZ, skip); // jmp skip,NZ |
| 1458 | 1046 | UML_MOV(block, I0, param); // mov i0,nextpc |
| 1459 | 1047 | UML_MOV(block, I1, compiler->cycles); // mov i1,cycles |
| 1460 | | UML_CALLH(block, *mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover |
| 1048 | UML_CALLH(block, *m_exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover |
| 1461 | 1049 | UML_LABEL(block, skip); // skip: |
| 1462 | 1050 | } |
| 1463 | 1051 | |
| 1464 | 1052 | /* account for cycles */ |
| 1465 | 1053 | if (compiler->cycles > 0) |
| 1466 | 1054 | { |
| 1467 | | UML_SUB(block, mem(&mips3->icount), mem(&mips3->icount), MAPVAR_CYCLES); // sub icount,icount,cycles |
| 1055 | UML_SUB(block, mem(&m_core->icount), mem(&m_core->icount), MAPVAR_CYCLES); // sub icount,icount,cycles |
| 1468 | 1056 | UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0 |
| 1469 | 1057 | if (allow_exception) |
| 1470 | | UML_EXHc(block, COND_S, *mips3->impstate->out_of_cycles, param); |
| 1058 | UML_EXHc(block, COND_S, *m_out_of_cycles, param); |
| 1471 | 1059 | // exh out_of_cycles,nextpc |
| 1472 | 1060 | } |
| 1473 | 1061 | compiler->cycles = 0; |
| r30757 | r30758 | |
| 1479 | 1067 | validate a sequence of opcodes |
| 1480 | 1068 | -------------------------------------------------*/ |
| 1481 | 1069 | |
| 1482 | | static void generate_checksum_block(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) |
| 1070 | void mips3_device::generate_checksum_block(drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) |
| 1483 | 1071 | { |
| 1484 | 1072 | const opcode_desc *curdesc; |
| 1485 | 1073 | if (LOG_UML) |
| 1486 | 1074 | block->append_comment("[Validation for %08X]", seqhead->pc); // comment |
| 1487 | 1075 | |
| 1488 | 1076 | /* loose verify or single instruction: just compare and fail */ |
| 1489 | | if (!(mips3->impstate->drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next() == NULL) |
| 1077 | if (!(m_drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next() == NULL) |
| 1490 | 1078 | { |
| 1491 | 1079 | if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) |
| 1492 | 1080 | { |
| 1493 | 1081 | UINT32 sum = seqhead->opptr.l[0]; |
| 1494 | | void *base = mips3->direct->read_decrypted_ptr(seqhead->physpc); |
| 1082 | void *base = m_direct->read_decrypted_ptr(seqhead->physpc); |
| 1495 | 1083 | UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword |
| 1496 | 1084 | |
| 1497 | 1085 | if (seqhead->delay.first() != NULL && seqhead->physpc != seqhead->delay.first()->physpc) |
| 1498 | 1086 | { |
| 1499 | | base = mips3->direct->read_decrypted_ptr(seqhead->delay.first()->physpc); |
| 1087 | base = m_direct->read_decrypted_ptr(seqhead->delay.first()->physpc); |
| 1500 | 1088 | UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword |
| 1501 | 1089 | UML_ADD(block, I0, I0, I1); // add i0,i0,i1 |
| 1502 | 1090 | |
| r30757 | r30758 | |
| 1504 | 1092 | } |
| 1505 | 1093 | |
| 1506 | 1094 | UML_CMP(block, I0, sum); // cmp i0,opptr[0] |
| 1507 | | UML_EXHc(block, COND_NE, *mips3->impstate->nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1095 | UML_EXHc(block, COND_NE, *m_nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1508 | 1096 | } |
| 1509 | 1097 | } |
| 1510 | 1098 | |
| r30757 | r30758 | |
| 1515 | 1103 | for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) |
| 1516 | 1104 | if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) |
| 1517 | 1105 | { |
| 1518 | | void *base = mips3->direct->read_decrypted_ptr(seqhead->physpc); |
| 1106 | void *base = m_direct->read_decrypted_ptr(seqhead->physpc); |
| 1519 | 1107 | UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword |
| 1520 | 1108 | UML_CMP(block, I0, curdesc->opptr.l[0]); // cmp i0,opptr[0] |
| 1521 | | UML_EXHc(block, COND_NE, *mips3->impstate->nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1109 | UML_EXHc(block, COND_NE, *m_nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1522 | 1110 | } |
| 1523 | 1111 | #else |
| 1524 | 1112 | UINT32 sum = 0; |
| 1525 | | void *base = mips3->direct->read_decrypted_ptr(seqhead->physpc); |
| 1113 | void *base = m_direct->read_decrypted_ptr(seqhead->physpc); |
| 1526 | 1114 | UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword |
| 1527 | 1115 | sum += seqhead->opptr.l[0]; |
| 1528 | 1116 | for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) |
| 1529 | 1117 | if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) |
| 1530 | 1118 | { |
| 1531 | | base = mips3->direct->read_decrypted_ptr(curdesc->physpc); |
| 1119 | base = m_direct->read_decrypted_ptr(curdesc->physpc); |
| 1532 | 1120 | UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword |
| 1533 | 1121 | UML_ADD(block, I0, I0, I1); // add i0,i0,i1 |
| 1534 | 1122 | sum += curdesc->opptr.l[0]; |
| 1535 | 1123 | |
| 1536 | 1124 | if (curdesc->delay.first() != NULL && (curdesc == seqlast || (curdesc->next() != NULL && curdesc->next()->physpc != curdesc->delay.first()->physpc))) |
| 1537 | 1125 | { |
| 1538 | | base = mips3->direct->read_decrypted_ptr(curdesc->delay.first()->physpc); |
| 1126 | base = m_direct->read_decrypted_ptr(curdesc->delay.first()->physpc); |
| 1539 | 1127 | UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword |
| 1540 | 1128 | UML_ADD(block, I0, I0, I1); // add i0,i0,i1 |
| 1541 | 1129 | sum += curdesc->delay.first()->opptr.l[0]; |
| 1542 | 1130 | } |
| 1543 | 1131 | } |
| 1544 | 1132 | UML_CMP(block, I0, sum); // cmp i0,sum |
| 1545 | | UML_EXHc(block, COND_NE, *mips3->impstate->nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1133 | UML_EXHc(block, COND_NE, *m_nocode, epc(seqhead)); // exne nocode,seqhead->pc |
| 1546 | 1134 | #endif |
| 1547 | 1135 | } |
| 1548 | 1136 | } |
| r30757 | r30758 | |
| 1553 | 1141 | for a single instruction in a sequence |
| 1554 | 1142 | -------------------------------------------------*/ |
| 1555 | 1143 | |
| 1556 | | static void generate_sequence_instruction(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 1144 | void mips3_device::generate_sequence_instruction(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 1557 | 1145 | { |
| 1558 | 1146 | offs_t expc; |
| 1559 | 1147 | int hotnum; |
| 1560 | 1148 | |
| 1561 | 1149 | /* add an entry for the log */ |
| 1562 | 1150 | if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) |
| 1563 | | log_add_disasm_comment(mips3, block, desc->pc, desc->opptr.l[0]); |
| 1151 | log_add_disasm_comment(block, desc->pc, desc->opptr.l[0]); |
| 1564 | 1152 | |
| 1565 | 1153 | /* set the PC map variable */ |
| 1566 | 1154 | expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; |
| r30757 | r30758 | |
| 1571 | 1159 | |
| 1572 | 1160 | /* is this a hotspot? */ |
| 1573 | 1161 | for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++) |
| 1574 | | if (mips3->impstate->hotspot[hotnum].pc != 0 && desc->pc == mips3->impstate->hotspot[hotnum].pc && desc->opptr.l[0] == mips3->impstate->hotspot[hotnum].opcode) |
| 1162 | if (m_hotspot[hotnum].pc != 0 && desc->pc == m_hotspot[hotnum].pc && desc->opptr.l[0] == m_hotspot[hotnum].opcode) |
| 1575 | 1163 | { |
| 1576 | | compiler->cycles += mips3->impstate->hotspot[hotnum].cycles; |
| 1164 | compiler->cycles += m_hotspot[hotnum].cycles; |
| 1577 | 1165 | break; |
| 1578 | 1166 | } |
| 1579 | 1167 | |
| r30757 | r30758 | |
| 1583 | 1171 | /* if we want a probe, add it here */ |
| 1584 | 1172 | if (desc->pc == PROBE_ADDRESS) |
| 1585 | 1173 | { |
| 1586 | | UML_MOV(block, mem(&mips3->pc), desc->pc); // mov [pc],desc->pc |
| 1587 | | UML_CALLC(block, cfunc_printf_probe, mips3); // callc cfunc_printf_probe,mips3 |
| 1174 | UML_MOV(block, mem(&m_core->pc), desc->pc); // mov [pc],desc->pc |
| 1175 | UML_CALLC(block, cfunc_printf_probe, this); // callc cfunc_printf_probe,mips3 |
| 1588 | 1176 | } |
| 1589 | 1177 | |
| 1590 | 1178 | /* if we are debugging, call the debugger */ |
| 1591 | | if ((mips3->device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) |
| 1179 | if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) |
| 1592 | 1180 | { |
| 1593 | | UML_MOV(block, mem(&mips3->pc), desc->pc); // mov [pc],desc->pc |
| 1594 | | save_fast_iregs(mips3, block); |
| 1181 | UML_MOV(block, mem(&m_core->pc), desc->pc); // mov [pc],desc->pc |
| 1182 | save_fast_iregs(block); |
| 1595 | 1183 | UML_DEBUG(block, desc->pc); // debug desc->pc |
| 1596 | 1184 | } |
| 1597 | 1185 | |
| 1598 | 1186 | /* if we hit an unmapped address, fatal error */ |
| 1599 | 1187 | if (desc->flags & OPFLAG_COMPILER_UNMAPPED) |
| 1600 | 1188 | { |
| 1601 | | UML_MOV(block, mem(&mips3->pc), desc->pc); // mov [pc],desc->pc |
| 1602 | | save_fast_iregs(mips3, block); |
| 1189 | UML_MOV(block, mem(&m_core->pc), desc->pc); // mov [pc],desc->pc |
| 1190 | save_fast_iregs(block); |
| 1603 | 1191 | UML_EXIT(block, EXECUTE_UNMAPPED_CODE); // exit EXECUTE_UNMAPPED_CODE |
| 1604 | 1192 | } |
| 1605 | 1193 | |
| r30757 | r30758 | |
| 1609 | 1197 | if (PRINTF_MMU) |
| 1610 | 1198 | { |
| 1611 | 1199 | static const char text[] = "Compiler page fault @ %08X"; |
| 1612 | | UML_MOV(block, mem(&mips3->impstate->format), (FPTR)text); // mov [format],text |
| 1613 | | UML_MOV(block, mem(&mips3->impstate->arg0), desc->pc); // mov [arg0],desc->pc |
| 1614 | | UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug |
| 1200 | UML_MOV(block, mem(&m_core->format), (FPTR)text); // mov [format],text |
| 1201 | UML_MOV(block, mem(&m_core->arg0), desc->pc); // mov [arg0],desc->pc |
| 1202 | UML_CALLC(block, cfunc_printf_debug, this); // callc printf_debug |
| 1615 | 1203 | } |
| 1616 | | UML_EXH(block, *mips3->impstate->tlb_mismatch, 0); // exh tlb_mismatch,0 |
| 1204 | UML_EXH(block, *m_tlb_mismatch, 0); // exh tlb_mismatch,0 |
| 1617 | 1205 | } |
| 1618 | 1206 | |
| 1619 | 1207 | /* validate our TLB entry at this PC; if we fail, we need to handle it */ |
| 1620 | 1208 | if ((desc->flags & OPFLAG_VALIDATE_TLB) && (desc->pc < 0x80000000 || desc->pc >= 0xc0000000)) |
| 1621 | 1209 | { |
| 1622 | | const vtlb_entry *tlbtable = vtlb_table(mips3->vtlb); |
| 1210 | const vtlb_entry *tlbtable = vtlb_table(m_vtlb); |
| 1623 | 1211 | |
| 1624 | 1212 | /* if we currently have a valid TLB read entry, we just verify */ |
| 1625 | 1213 | if (tlbtable[desc->pc >> 12] & VTLB_FETCH_ALLOWED) |
| r30757 | r30758 | |
| 1627 | 1215 | if (PRINTF_MMU) |
| 1628 | 1216 | { |
| 1629 | 1217 | static const char text[] = "Checking TLB at @ %08X\n"; |
| 1630 | | UML_MOV(block, mem(&mips3->impstate->format), (FPTR)text); // mov [format],text |
| 1631 | | UML_MOV(block, mem(&mips3->impstate->arg0), desc->pc); // mov [arg0],desc->pc |
| 1632 | | UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug |
| 1218 | UML_MOV(block, mem(&m_core->format), (FPTR)text); // mov [format],text |
| 1219 | UML_MOV(block, mem(&m_core->arg0), desc->pc); // mov [arg0],desc->pc |
| 1220 | UML_CALLC(block, cfunc_printf_debug, this); // callc printf_debug |
| 1633 | 1221 | } |
| 1634 | 1222 | UML_LOAD(block, I0, &tlbtable[desc->pc >> 12], 0, SIZE_DWORD, SCALE_x4); // load i0,tlbtable[desc->pc >> 12],0,dword |
| 1635 | 1223 | UML_CMP(block, I0, tlbtable[desc->pc >> 12]); // cmp i0,*tlbentry |
| 1636 | | UML_EXHc(block, COND_NE, *mips3->impstate->tlb_mismatch, 0); // exh tlb_mismatch,0,NE |
| 1224 | UML_EXHc(block, COND_NE, *m_tlb_mismatch, 0); // exh tlb_mismatch,0,NE |
| 1637 | 1225 | } |
| 1638 | 1226 | |
| 1639 | 1227 | /* otherwise, we generate an unconditional exception */ |
| r30757 | r30758 | |
| 1642 | 1230 | if (PRINTF_MMU) |
| 1643 | 1231 | { |
| 1644 | 1232 | static const char text[] = "No valid TLB @ %08X\n"; |
| 1645 | | UML_MOV(block, mem(&mips3->impstate->format), (FPTR)text); // mov [format],text |
| 1646 | | UML_MOV(block, mem(&mips3->impstate->arg0), desc->pc); // mov [arg0],desc->pc |
| 1647 | | UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug |
| 1233 | UML_MOV(block, mem(&m_core->format), (FPTR)text); // mov [format],text |
| 1234 | UML_MOV(block, mem(&m_core->arg0), desc->pc); // mov [arg0],desc->pc |
| 1235 | UML_CALLC(block, cfunc_printf_debug, this); // callc printf_debug |
| 1648 | 1236 | } |
| 1649 | | UML_EXH(block, *mips3->impstate->tlb_mismatch, 0); // exh tlb_mismatch,0 |
| 1237 | UML_EXH(block, *m_tlb_mismatch, 0); // exh tlb_mismatch,0 |
| 1650 | 1238 | } |
| 1651 | 1239 | } |
| 1652 | 1240 | |
| 1653 | 1241 | /* if this is an invalid opcode, generate the exception now */ |
| 1654 | 1242 | if (desc->flags & OPFLAG_INVALID_OPCODE) |
| 1655 | | UML_EXH(block, *mips3->impstate->exception[EXCEPTION_INVALIDOP], 0); // exh invalidop,0 |
| 1243 | UML_EXH(block, *m_exception[EXCEPTION_INVALIDOP], 0); // exh invalidop,0 |
| 1656 | 1244 | |
| 1657 | 1245 | /* otherwise, unless this is a virtual no-op, it's a regular instruction */ |
| 1658 | 1246 | else if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) |
| 1659 | 1247 | { |
| 1660 | 1248 | /* compile the instruction */ |
| 1661 | | if (!generate_opcode(mips3, block, compiler, desc)) |
| 1249 | if (!generate_opcode(block, compiler, desc)) |
| 1662 | 1250 | { |
| 1663 | | UML_MOV(block, mem(&mips3->pc), desc->pc); // mov [pc],desc->pc |
| 1664 | | UML_MOV(block, mem(&mips3->impstate->arg0), desc->opptr.l[0]); // mov [arg0],desc->opptr.l |
| 1665 | | UML_CALLC(block, cfunc_unimplemented, mips3); // callc cfunc_unimplemented |
| 1251 | UML_MOV(block, mem(&m_core->pc), desc->pc); // mov [pc],desc->pc |
| 1252 | UML_MOV(block, mem(&m_core->arg0), desc->opptr.l[0]); // mov [arg0],desc->opptr.l |
| 1253 | UML_CALLC(block, cfunc_unimplemented, this); // callc cfunc_unimplemented |
| 1666 | 1254 | } |
| 1667 | 1255 | } |
| 1668 | 1256 | } |
| r30757 | r30758 | |
| 1672 | 1260 | generate_delay_slot_and_branch |
| 1673 | 1261 | ------------------------------------------------------------------*/ |
| 1674 | 1262 | |
| 1675 | | static void generate_delay_slot_and_branch(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 linkreg) |
| 1263 | void mips3_device::generate_delay_slot_and_branch(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 linkreg) |
| 1676 | 1264 | { |
| 1677 | 1265 | compiler_state compiler_temp = *compiler; |
| 1678 | 1266 | UINT32 op = desc->opptr.l[0]; |
| r30757 | r30758 | |
| 1680 | 1268 | /* fetch the target register if dynamic, in case it is modified by the delay slot */ |
| 1681 | 1269 | if (desc->targetpc == BRANCH_TARGET_DYNAMIC) |
| 1682 | 1270 | { |
| 1683 | | UML_MOV(block, mem(&mips3->impstate->jmpdest), R32(RSREG)); // mov [jmpdest],<rsreg> |
| 1271 | UML_MOV(block, mem(&m_core->jmpdest), R32(RSREG)); // mov [jmpdest],<rsreg> |
| 1684 | 1272 | |
| 1685 | 1273 | } |
| 1686 | 1274 | |
| r30757 | r30758 | |
| 1692 | 1280 | |
| 1693 | 1281 | /* compile the delay slot using temporary compiler state */ |
| 1694 | 1282 | assert(desc->delay.first() != NULL); |
| 1695 | | generate_sequence_instruction(mips3, block, &compiler_temp, desc->delay.first()); // <next instruction> |
| 1283 | generate_sequence_instruction(block, &compiler_temp, desc->delay.first()); // <next instruction> |
| 1696 | 1284 | |
| 1697 | 1285 | /* update the cycles and jump through the hash table to the target */ |
| 1698 | 1286 | if (desc->targetpc != BRANCH_TARGET_DYNAMIC) |
| 1699 | 1287 | { |
| 1700 | | generate_update_cycles(mips3, block, &compiler_temp, desc->targetpc, TRUE); // <subtract cycles> |
| 1288 | generate_update_cycles(block, &compiler_temp, desc->targetpc, TRUE); // <subtract cycles> |
| 1701 | 1289 | if (desc->flags & OPFLAG_INTRABLOCK_BRANCH) |
| 1702 | 1290 | UML_JMP(block, desc->targetpc | 0x80000000); // jmp desc->targetpc | 0x80000000 |
| 1703 | 1291 | else |
| 1704 | | UML_HASHJMP(block, mips3->impstate->mode, desc->targetpc, *mips3->impstate->nocode); |
| 1292 | UML_HASHJMP(block, m_core->mode, desc->targetpc, *m_nocode); |
| 1705 | 1293 | // hashjmp <mode>,desc->targetpc,nocode |
| 1706 | 1294 | } |
| 1707 | 1295 | else |
| 1708 | 1296 | { |
| 1709 | | generate_update_cycles(mips3, block, &compiler_temp, mem(&mips3->impstate->jmpdest), TRUE); |
| 1297 | generate_update_cycles(block, &compiler_temp, mem(&m_core->jmpdest), TRUE); |
| 1710 | 1298 | // <subtract cycles> |
| 1711 | | UML_HASHJMP(block, mips3->impstate->mode, mem(&mips3->impstate->jmpdest), *mips3->impstate->nocode); |
| 1299 | UML_HASHJMP(block, m_core->mode, mem(&m_core->jmpdest), *m_nocode); |
| 1712 | 1300 | // hashjmp <mode>,<rsreg>,nocode |
| 1713 | 1301 | } |
| 1714 | 1302 | |
| r30757 | r30758 | |
| 1726 | 1314 | opcode |
| 1727 | 1315 | -------------------------------------------------*/ |
| 1728 | 1316 | |
| 1729 | | static int generate_opcode(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 1317 | int mips3_device::generate_opcode(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 1730 | 1318 | { |
| 1731 | 1319 | int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0); |
| 1732 | 1320 | UINT32 op = desc->opptr.l[0]; |
| r30757 | r30758 | |
| 1738 | 1326 | /* ----- sub-groups ----- */ |
| 1739 | 1327 | |
| 1740 | 1328 | case 0x00: /* SPECIAL - MIPS I */ |
| 1741 | | return generate_special(mips3, block, compiler, desc); |
| 1329 | return generate_special(block, compiler, desc); |
| 1742 | 1330 | |
| 1743 | 1331 | case 0x01: /* REGIMM - MIPS I */ |
| 1744 | | return generate_regimm(mips3, block, compiler, desc); |
| 1332 | return generate_regimm(block, compiler, desc); |
| 1745 | 1333 | |
| 1746 | 1334 | case 0x1c: /* IDT-specific */ |
| 1747 | | return generate_idt(mips3, block, compiler, desc); |
| 1335 | return generate_idt(block, compiler, desc); |
| 1748 | 1336 | |
| 1749 | 1337 | |
| 1750 | 1338 | /* ----- jumps and branches ----- */ |
| 1751 | 1339 | |
| 1752 | 1340 | case 0x02: /* J - MIPS I */ |
| 1753 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1341 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1754 | 1342 | return TRUE; |
| 1755 | 1343 | |
| 1756 | 1344 | case 0x03: /* JAL - MIPS I */ |
| 1757 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 31); // <next instruction + hashjmp> |
| 1345 | generate_delay_slot_and_branch(block, compiler, desc, 31); // <next instruction + hashjmp> |
| 1758 | 1346 | return TRUE; |
| 1759 | 1347 | |
| 1760 | 1348 | case 0x04: /* BEQ - MIPS I */ |
| 1761 | 1349 | case 0x14: /* BEQL - MIPS II */ |
| 1762 | 1350 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 1763 | 1351 | UML_JMPc(block, COND_NE, skip = compiler->labelnum++); // jmp skip,NE |
| 1764 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1352 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1765 | 1353 | UML_LABEL(block, skip); // skip: |
| 1766 | 1354 | return TRUE; |
| 1767 | 1355 | |
| r30757 | r30758 | |
| 1769 | 1357 | case 0x15: /* BNEL - MIPS II */ |
| 1770 | 1358 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 1771 | 1359 | UML_JMPc(block, COND_E, skip = compiler->labelnum++); // jmp skip,E |
| 1772 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1360 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1773 | 1361 | UML_LABEL(block, skip); // skip: |
| 1774 | 1362 | return TRUE; |
| 1775 | 1363 | |
| r30757 | r30758 | |
| 1779 | 1367 | { |
| 1780 | 1368 | UML_DCMP(block, R64(RSREG), 0); // dcmp <rsreg>,0 |
| 1781 | 1369 | UML_JMPc(block, COND_G, skip = compiler->labelnum++); // jmp skip,G |
| 1782 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1370 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1783 | 1371 | UML_LABEL(block, skip); // skip: |
| 1784 | 1372 | } |
| 1785 | 1373 | else |
| 1786 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1374 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1787 | 1375 | return TRUE; |
| 1788 | 1376 | |
| 1789 | 1377 | case 0x07: /* BGTZ - MIPS I */ |
| 1790 | 1378 | case 0x17: /* BGTZL - MIPS II */ |
| 1791 | 1379 | UML_DCMP(block, R64(RSREG), 0); // dcmp <rsreg>,0 |
| 1792 | 1380 | UML_JMPc(block, COND_LE, skip = compiler->labelnum++); // jmp skip,LE |
| 1793 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1381 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 1794 | 1382 | UML_LABEL(block, skip); // skip: |
| 1795 | 1383 | return TRUE; |
| 1796 | 1384 | |
| r30757 | r30758 | |
| 1804 | 1392 | |
| 1805 | 1393 | case 0x08: /* ADDI - MIPS I */ |
| 1806 | 1394 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1807 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1808 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 1395 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1396 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 1809 | 1397 | // exh overflow,0 |
| 1810 | 1398 | if (RTREG != 0) |
| 1811 | 1399 | UML_DSEXT(block, R64(RTREG), I0, SIZE_DWORD); // dsext <rtreg>,i0,dword |
| r30757 | r30758 | |
| 1821 | 1409 | |
| 1822 | 1410 | case 0x18: /* DADDI - MIPS III */ |
| 1823 | 1411 | UML_DADD(block, I0, R64(RSREG), SIMMVAL); // dadd i0,<rsreg>,SIMMVAL |
| 1824 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1825 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 1412 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1413 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 1826 | 1414 | // exh overflow,0 |
| 1827 | 1415 | if (RTREG != 0) |
| 1828 | 1416 | UML_DMOV(block, R64(RTREG), I0); // dmov <rtreg>,i0 |
| r30757 | r30758 | |
| 1869 | 1457 | |
| 1870 | 1458 | case 0x20: /* LB - MIPS I */ |
| 1871 | 1459 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1872 | | UML_CALLH(block, *mips3->impstate->read8[mips3->impstate->mode >> 1]); // callh read8 |
| 1460 | UML_CALLH(block, *m_read8[m_core->mode >> 1]); // callh read8 |
| 1873 | 1461 | if (RTREG != 0) |
| 1874 | 1462 | UML_DSEXT(block, R64(RTREG), I0, SIZE_BYTE); // dsext <rtreg>,i0,byte |
| 1875 | 1463 | if (!in_delay_slot) |
| 1876 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1464 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1877 | 1465 | return TRUE; |
| 1878 | 1466 | |
| 1879 | 1467 | case 0x21: /* LH - MIPS I */ |
| 1880 | 1468 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1881 | | UML_CALLH(block, *mips3->impstate->read16[mips3->impstate->mode >> 1]); // callh read16 |
| 1469 | UML_CALLH(block, *m_read16[m_core->mode >> 1]); // callh read16 |
| 1882 | 1470 | if (RTREG != 0) |
| 1883 | 1471 | UML_DSEXT(block, R64(RTREG), I0, SIZE_WORD); // dsext <rtreg>,i0,word |
| 1884 | 1472 | if (!in_delay_slot) |
| 1885 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1473 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1886 | 1474 | return TRUE; |
| 1887 | 1475 | |
| 1888 | 1476 | case 0x23: /* LW - MIPS I */ |
| 1889 | 1477 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1890 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 1478 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 1891 | 1479 | if (RTREG != 0) |
| 1892 | 1480 | UML_DSEXT(block, R64(RTREG), I0, SIZE_DWORD); // dsext <rtreg>,i0 |
| 1893 | 1481 | if (!in_delay_slot) |
| 1894 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1482 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1895 | 1483 | return TRUE; |
| 1896 | 1484 | |
| 1897 | 1485 | case 0x30: /* LL - MIPS II */ |
| 1898 | 1486 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1899 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 1487 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 1900 | 1488 | if (RTREG != 0) |
| 1901 | 1489 | UML_DSEXT(block, R64(RTREG), I0, SIZE_DWORD); // dsext <rtreg>,i0 |
| 1902 | | UML_MOV(block, mem(&mips3->llbit), 1); // mov [llbit],1 |
| 1490 | UML_MOV(block, mem(&m_core->llbit), 1); // mov [llbit],1 |
| 1903 | 1491 | if (!in_delay_slot) |
| 1904 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1492 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1905 | 1493 | return TRUE; |
| 1906 | 1494 | |
| 1907 | 1495 | case 0x24: /* LBU - MIPS I */ |
| 1908 | 1496 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1909 | | UML_CALLH(block, *mips3->impstate->read8[mips3->impstate->mode >> 1]); // callh read8 |
| 1497 | UML_CALLH(block, *m_read8[m_core->mode >> 1]); // callh read8 |
| 1910 | 1498 | if (RTREG != 0) |
| 1911 | 1499 | UML_DAND(block, R64(RTREG), I0, 0xff); // dand <rtreg>,i0,0xff |
| 1912 | 1500 | if (!in_delay_slot) |
| 1913 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1501 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1914 | 1502 | return TRUE; |
| 1915 | 1503 | |
| 1916 | 1504 | case 0x25: /* LHU - MIPS I */ |
| 1917 | 1505 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1918 | | UML_CALLH(block, *mips3->impstate->read16[mips3->impstate->mode >> 1]); // callh read16 |
| 1506 | UML_CALLH(block, *m_read16[m_core->mode >> 1]); // callh read16 |
| 1919 | 1507 | if (RTREG != 0) |
| 1920 | 1508 | UML_DAND(block, R64(RTREG), I0, 0xffff); // dand <rtreg>,i0,0xffff |
| 1921 | 1509 | if (!in_delay_slot) |
| 1922 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1510 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1923 | 1511 | return TRUE; |
| 1924 | 1512 | |
| 1925 | 1513 | case 0x27: /* LWU - MIPS III */ |
| 1926 | 1514 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1927 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 1515 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 1928 | 1516 | if (RTREG != 0) |
| 1929 | 1517 | UML_DAND(block, R64(RTREG), I0, 0xffffffff); // dand <rtreg>,i0,0xffffffff |
| 1930 | 1518 | if (!in_delay_slot) |
| 1931 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1519 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1932 | 1520 | return TRUE; |
| 1933 | 1521 | |
| 1934 | 1522 | case 0x37: /* LD - MIPS III */ |
| 1935 | 1523 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1936 | | UML_CALLH(block, *mips3->impstate->read64[mips3->impstate->mode >> 1]); // callh read64 |
| 1524 | UML_CALLH(block, *m_read64[m_core->mode >> 1]); // callh read64 |
| 1937 | 1525 | if (RTREG != 0) |
| 1938 | 1526 | UML_DMOV(block, R64(RTREG), I0); // dmov <rtreg>,i0 |
| 1939 | 1527 | if (!in_delay_slot) |
| 1940 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1528 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1941 | 1529 | return TRUE; |
| 1942 | 1530 | |
| 1943 | 1531 | case 0x34: /* LLD - MIPS III */ |
| 1944 | 1532 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1945 | | UML_CALLH(block, *mips3->impstate->read64[mips3->impstate->mode >> 1]); // callh read64 |
| 1533 | UML_CALLH(block, *m_read64[m_core->mode >> 1]); // callh read64 |
| 1946 | 1534 | if (RTREG != 0) |
| 1947 | 1535 | UML_DMOV(block, R64(RTREG), I0); // dmov <rtreg>,i0 |
| 1948 | | UML_MOV(block, mem(&mips3->llbit), 1); // mov [llbit],1 |
| 1536 | UML_MOV(block, mem(&m_core->llbit), 1); // mov [llbit],1 |
| 1949 | 1537 | if (!in_delay_slot) |
| 1950 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1538 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1951 | 1539 | return TRUE; |
| 1952 | 1540 | |
| 1953 | 1541 | case 0x22: /* LWL - MIPS I */ |
| 1954 | 1542 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1955 | 1543 | UML_SHL(block, I1, I0, 3); // shl i1,i0,3 |
| 1956 | 1544 | UML_AND(block, I0, I0, ~3); // and i0,i0,~3 |
| 1957 | | if (!mips3->bigendian) |
| 1545 | if (!m_bigendian) |
| 1958 | 1546 | UML_XOR(block, I1, I1, 0x18); // xor i1,i1,0x18 |
| 1959 | 1547 | UML_SHR(block, I2, ~0, I1); // shr i2,~0,i1 |
| 1960 | | UML_CALLH(block, *mips3->impstate->read32mask[mips3->impstate->mode >> 1]); |
| 1548 | UML_CALLH(block, *m_read32mask[m_core->mode >> 1]); |
| 1961 | 1549 | // callh read32mask |
| 1962 | 1550 | if (RTREG != 0) |
| 1963 | 1551 | { |
| r30757 | r30758 | |
| 1967 | 1555 | UML_DSEXT(block, R64(RTREG), I3, SIZE_DWORD); // dsext <rtreg>,i3,dword |
| 1968 | 1556 | } |
| 1969 | 1557 | if (!in_delay_slot) |
| 1970 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1558 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1971 | 1559 | return TRUE; |
| 1972 | 1560 | |
| 1973 | 1561 | case 0x26: /* LWR - MIPS I */ |
| 1974 | 1562 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1975 | 1563 | UML_SHL(block, I1, I0, 3); // shl i1,i0,3 |
| 1976 | 1564 | UML_AND(block, I0, I0, ~3); // and i0,i0,~3 |
| 1977 | | if (mips3->bigendian) |
| 1565 | if (m_bigendian) |
| 1978 | 1566 | UML_XOR(block, I1, I1, 0x18); // xor i1,i1,0x18 |
| 1979 | 1567 | UML_SHL(block, I2, ~0, I1); // shl i2,~0,i1 |
| 1980 | | UML_CALLH(block, *mips3->impstate->read32mask[mips3->impstate->mode >> 1]); |
| 1568 | UML_CALLH(block, *m_read32mask[m_core->mode >> 1]); |
| 1981 | 1569 | // callh read32mask |
| 1982 | 1570 | if (RTREG != 0) |
| 1983 | 1571 | { |
| r30757 | r30758 | |
| 1988 | 1576 | UML_DSEXT(block, R64(RTREG), I3, SIZE_DWORD); // dsext <rtreg>,i3,dword |
| 1989 | 1577 | } |
| 1990 | 1578 | if (!in_delay_slot) |
| 1991 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1579 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 1992 | 1580 | return TRUE; |
| 1993 | 1581 | |
| 1994 | 1582 | case 0x1a: /* LDL - MIPS III */ |
| 1995 | 1583 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 1996 | 1584 | UML_SHL(block, I1, I0, 3); // shl i1,i0,3 |
| 1997 | 1585 | UML_AND(block, I0, I0, ~7); // and i0,i0,~7 |
| 1998 | | if (!mips3->bigendian) |
| 1586 | if (!m_bigendian) |
| 1999 | 1587 | UML_XOR(block, I1, I1, 0x38); // xor i1,i1,0x38 |
| 2000 | 1588 | UML_DSHR(block, I2, (UINT64)~0, I1); // dshr i2,~0,i1 |
| 2001 | | UML_CALLH(block, *mips3->impstate->read64mask[mips3->impstate->mode >> 1]); |
| 1589 | UML_CALLH(block, *m_read64mask[m_core->mode >> 1]); |
| 2002 | 1590 | // callh read64mask |
| 2003 | 1591 | if (RTREG != 0) |
| 2004 | 1592 | { |
| r30757 | r30758 | |
| 2006 | 1594 | UML_DROLINS(block, R64(RTREG), I0, I1, I2); // drolins <rtreg>,i0,i1,i2 |
| 2007 | 1595 | } |
| 2008 | 1596 | if (!in_delay_slot) |
| 2009 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1597 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2010 | 1598 | return TRUE; |
| 2011 | 1599 | |
| 2012 | 1600 | case 0x1b: /* LDR - MIPS III */ |
| 2013 | 1601 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2014 | 1602 | UML_SHL(block, I1, I0, 3); // shl i1,i0,3 |
| 2015 | 1603 | UML_AND(block, I0, I0, ~7); // and i0,i0,~7 |
| 2016 | | if (mips3->bigendian) |
| 1604 | if (m_bigendian) |
| 2017 | 1605 | UML_XOR(block, I1, I1, 0x38); // xor i1,i1,0x38 |
| 2018 | 1606 | UML_DSHL(block, I2, (UINT64)~0, I1); // dshl i2,~0,i1 |
| 2019 | | UML_CALLH(block, *mips3->impstate->read64mask[mips3->impstate->mode >> 1]); |
| 1607 | UML_CALLH(block, *m_read64mask[m_core->mode >> 1]); |
| 2020 | 1608 | // callh read64mask |
| 2021 | 1609 | if (RTREG != 0) |
| 2022 | 1610 | { |
| r30757 | r30758 | |
| 2025 | 1613 | UML_DROLINS(block, R64(RTREG), I0, I1, I2); // drolins <rtreg>,i0,i1,i2 |
| 2026 | 1614 | } |
| 2027 | 1615 | if (!in_delay_slot) |
| 2028 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1616 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2029 | 1617 | return TRUE; |
| 2030 | 1618 | |
| 2031 | 1619 | case 0x31: /* LWC1 - MIPS I */ |
| 2032 | 1620 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2033 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 1621 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 2034 | 1622 | UML_MOV(block, FPR32(RTREG), I0); // mov <cpr1_rt>,i0 |
| 2035 | 1623 | if (!in_delay_slot) |
| 2036 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1624 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2037 | 1625 | return TRUE; |
| 2038 | 1626 | |
| 2039 | 1627 | case 0x35: /* LDC1 - MIPS III */ |
| 2040 | 1628 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2041 | | UML_CALLH(block, *mips3->impstate->read64[mips3->impstate->mode >> 1]); // callh read64 |
| 1629 | UML_CALLH(block, *m_read64[m_core->mode >> 1]); // callh read64 |
| 2042 | 1630 | UML_DMOV(block, FPR64(RTREG), I0); // dmov <cpr1_rt>,i0 |
| 2043 | 1631 | if (!in_delay_slot) |
| 2044 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1632 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2045 | 1633 | return TRUE; |
| 2046 | 1634 | |
| 2047 | 1635 | case 0x32: /* LWC2 - MIPS I */ |
| 2048 | 1636 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2049 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 1637 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 2050 | 1638 | UML_DAND(block, CPR264(RTREG), I0, 0xffffffff); // dand <cpr2_rt>,i0,0xffffffff |
| 2051 | 1639 | if (!in_delay_slot) |
| 2052 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1640 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2053 | 1641 | return TRUE; |
| 2054 | 1642 | |
| 2055 | 1643 | case 0x36: /* LDC2 - MIPS II */ |
| 2056 | 1644 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2057 | | UML_CALLH(block, *mips3->impstate->read64[mips3->impstate->mode >> 1]); // callh read64 |
| 1645 | UML_CALLH(block, *m_read64[m_core->mode >> 1]); // callh read64 |
| 2058 | 1646 | UML_DMOV(block, CPR264(RTREG), I0); // dmov <cpr2_rt>,i0 |
| 2059 | 1647 | if (!in_delay_slot) |
| 2060 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1648 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2061 | 1649 | return TRUE; |
| 2062 | 1650 | |
| 2063 | 1651 | |
| r30757 | r30758 | |
| 2066 | 1654 | case 0x28: /* SB - MIPS I */ |
| 2067 | 1655 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2068 | 1656 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2069 | | UML_CALLH(block, *mips3->impstate->write8[mips3->impstate->mode >> 1]); // callh write8 |
| 1657 | UML_CALLH(block, *m_write8[m_core->mode >> 1]); // callh write8 |
| 2070 | 1658 | if (!in_delay_slot) |
| 2071 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1659 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2072 | 1660 | return TRUE; |
| 2073 | 1661 | |
| 2074 | 1662 | case 0x29: /* SH - MIPS I */ |
| 2075 | 1663 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2076 | 1664 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2077 | | UML_CALLH(block, *mips3->impstate->write16[mips3->impstate->mode >> 1]); // callh write16 |
| 1665 | UML_CALLH(block, *m_write16[m_core->mode >> 1]); // callh write16 |
| 2078 | 1666 | if (!in_delay_slot) |
| 2079 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1667 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2080 | 1668 | return TRUE; |
| 2081 | 1669 | |
| 2082 | 1670 | case 0x2b: /* SW - MIPS I */ |
| 2083 | 1671 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2084 | 1672 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2085 | | UML_CALLH(block, *mips3->impstate->write32[mips3->impstate->mode >> 1]); // callh write32 |
| 1673 | UML_CALLH(block, *m_write32[m_core->mode >> 1]); // callh write32 |
| 2086 | 1674 | if (!in_delay_slot) |
| 2087 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1675 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2088 | 1676 | return TRUE; |
| 2089 | 1677 | |
| 2090 | 1678 | case 0x38: /* SC - MIPS II */ |
| 2091 | | UML_CMP(block, mem(&mips3->llbit), 0); // cmp [llbit],0 |
| 1679 | UML_CMP(block, mem(&m_core->llbit), 0); // cmp [llbit],0 |
| 2092 | 1680 | UML_JMPc(block, COND_E, skip = compiler->labelnum++); // je skip |
| 2093 | 1681 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2094 | 1682 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2095 | | UML_CALLH(block, *mips3->impstate->write32[mips3->impstate->mode >> 1]); // callh write32 |
| 1683 | UML_CALLH(block, *m_write32[m_core->mode >> 1]); // callh write32 |
| 2096 | 1684 | UML_LABEL(block, skip); // skip: |
| 2097 | | UML_DSEXT(block, R64(RTREG), mem(&mips3->llbit), SIZE_DWORD); // dsext <rtreg>,[llbit],dword |
| 1685 | UML_DSEXT(block, R64(RTREG), mem(&m_core->llbit), SIZE_DWORD); // dsext <rtreg>,[llbit],dword |
| 2098 | 1686 | if (!in_delay_slot) |
| 2099 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1687 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2100 | 1688 | return TRUE; |
| 2101 | 1689 | |
| 2102 | 1690 | case 0x3f: /* SD - MIPS III */ |
| 2103 | 1691 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2104 | 1692 | UML_DMOV(block, I1, R64(RTREG)); // dmov i1,<rtreg> |
| 2105 | | UML_CALLH(block, *mips3->impstate->write64[mips3->impstate->mode >> 1]); // callh write64 |
| 1693 | UML_CALLH(block, *m_write64[m_core->mode >> 1]); // callh write64 |
| 2106 | 1694 | if (!in_delay_slot) |
| 2107 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1695 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2108 | 1696 | return TRUE; |
| 2109 | 1697 | |
| 2110 | 1698 | case 0x3c: /* SCD - MIPS III */ |
| 2111 | | UML_CMP(block, mem(&mips3->llbit), 0); // cmp [llbit],0 |
| 1699 | UML_CMP(block, mem(&m_core->llbit), 0); // cmp [llbit],0 |
| 2112 | 1700 | UML_JMPc(block, COND_E, skip = compiler->labelnum++); // je skip |
| 2113 | 1701 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2114 | 1702 | UML_DMOV(block, I1, R64(RTREG)); // dmov i1,<rtreg> |
| 2115 | | UML_CALLH(block, *mips3->impstate->write64[mips3->impstate->mode >> 1]); // callh write64 |
| 1703 | UML_CALLH(block, *m_write64[m_core->mode >> 1]); // callh write64 |
| 2116 | 1704 | UML_LABEL(block, skip); // skip: |
| 2117 | | UML_DSEXT(block, R64(RTREG), mem(&mips3->llbit), SIZE_DWORD); // dsext <rtreg>,[llbit],dword |
| 1705 | UML_DSEXT(block, R64(RTREG), mem(&m_core->llbit), SIZE_DWORD); // dsext <rtreg>,[llbit],dword |
| 2118 | 1706 | if (!in_delay_slot) |
| 2119 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1707 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2120 | 1708 | return TRUE; |
| 2121 | 1709 | |
| 2122 | 1710 | case 0x2a: /* SWL - MIPS I */ |
| r30757 | r30758 | |
| 2124 | 1712 | UML_SHL(block, I3, I0, 3); // shl i3,i0,3 |
| 2125 | 1713 | UML_AND(block, I0, I0, ~3); // and i0,i0,~3 |
| 2126 | 1714 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2127 | | if (!mips3->bigendian) |
| 1715 | if (!m_bigendian) |
| 2128 | 1716 | UML_XOR(block, I3, I3, 0x18); // xor i3,i3,0x18 |
| 2129 | 1717 | UML_SHR(block, I2, ~0, I3); // shr i2,~0,i3 |
| 2130 | 1718 | UML_SHR(block, I1, I1, I3); // shr i1,i1,i3 |
| 2131 | | UML_CALLH(block, *mips3->impstate->write32mask[mips3->impstate->mode >> 1]); |
| 1719 | UML_CALLH(block, *m_write32mask[m_core->mode >> 1]); |
| 2132 | 1720 | // callh write32mask |
| 2133 | 1721 | if (!in_delay_slot) |
| 2134 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1722 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2135 | 1723 | return TRUE; |
| 2136 | 1724 | |
| 2137 | 1725 | case 0x2e: /* SWR - MIPS I */ |
| r30757 | r30758 | |
| 2139 | 1727 | UML_SHL(block, I3, I0, 3); // shl i3,i0,3 |
| 2140 | 1728 | UML_AND(block, I0, I0, ~3); // and i0,i0,~3 |
| 2141 | 1729 | UML_MOV(block, I1, R32(RTREG)); // mov i1,<rtreg> |
| 2142 | | if (mips3->bigendian) |
| 1730 | if (m_bigendian) |
| 2143 | 1731 | UML_XOR(block, I3, I3, 0x18); // xor i3,i3,0x18 |
| 2144 | 1732 | UML_SHL(block, I2, ~0, I3); // shl i2,~0,i3 |
| 2145 | 1733 | UML_SHL(block, I1, I1, I3); // shl i1,i1,i3 |
| 2146 | | UML_CALLH(block, *mips3->impstate->write32mask[mips3->impstate->mode >> 1]); |
| 1734 | UML_CALLH(block, *m_write32mask[m_core->mode >> 1]); |
| 2147 | 1735 | // callh write32mask |
| 2148 | 1736 | if (!in_delay_slot) |
| 2149 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1737 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2150 | 1738 | return TRUE; |
| 2151 | 1739 | |
| 2152 | 1740 | case 0x2c: /* SDL - MIPS III */ |
| r30757 | r30758 | |
| 2154 | 1742 | UML_SHL(block, I3, I0, 3); // shl i3,i0,3 |
| 2155 | 1743 | UML_AND(block, I0, I0, ~7); // and i0,i0,~7 |
| 2156 | 1744 | UML_DMOV(block, I1, R64(RTREG)); // dmov i1,<rtreg> |
| 2157 | | if (!mips3->bigendian) |
| 1745 | if (!m_bigendian) |
| 2158 | 1746 | UML_XOR(block, I3, I3, 0x38); // xor i3,i3,0x38 |
| 2159 | 1747 | UML_DSHR(block, I2, (UINT64)~0, I3); // dshr i2,~0,i3 |
| 2160 | 1748 | UML_DSHR(block, I1, I1, I3); // dshr i1,i1,i3 |
| 2161 | | UML_CALLH(block, *mips3->impstate->write64mask[mips3->impstate->mode >> 1]); |
| 1749 | UML_CALLH(block, *m_write64mask[m_core->mode >> 1]); |
| 2162 | 1750 | // callh write64mask |
| 2163 | 1751 | if (!in_delay_slot) |
| 2164 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1752 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2165 | 1753 | return TRUE; |
| 2166 | 1754 | |
| 2167 | 1755 | case 0x2d: /* SDR - MIPS III */ |
| r30757 | r30758 | |
| 2169 | 1757 | UML_SHL(block, I3, I0, 3); // shl i3,i0,3 |
| 2170 | 1758 | UML_AND(block, I0, I0, ~7); // and i0,i0,~7 |
| 2171 | 1759 | UML_DMOV(block, I1, R64(RTREG)); // dmov i1,<rtreg> |
| 2172 | | if (mips3->bigendian) |
| 1760 | if (m_bigendian) |
| 2173 | 1761 | UML_XOR(block, I3, I3, 0x38); // xor i3,i3,0x38 |
| 2174 | 1762 | UML_DSHL(block, I2, (UINT64)~0, I3); // dshl i2,~0,i3 |
| 2175 | 1763 | UML_DSHL(block, I1, I1, I3); // dshl i1,i1,i3 |
| 2176 | | UML_CALLH(block, *mips3->impstate->write64mask[mips3->impstate->mode >> 1]); |
| 1764 | UML_CALLH(block, *m_write64mask[m_core->mode >> 1]); |
| 2177 | 1765 | // callh write64mask |
| 2178 | 1766 | if (!in_delay_slot) |
| 2179 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1767 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2180 | 1768 | return TRUE; |
| 2181 | 1769 | |
| 2182 | 1770 | case 0x39: /* SWC1 - MIPS I */ |
| 2183 | 1771 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2184 | 1772 | UML_MOV(block, I1, FPR32(RTREG)); // mov i1,<cpr1_rt> |
| 2185 | | UML_CALLH(block, *mips3->impstate->write32[mips3->impstate->mode >> 1]); // callh write32 |
| 1773 | UML_CALLH(block, *m_write32[m_core->mode >> 1]); // callh write32 |
| 2186 | 1774 | if (!in_delay_slot) |
| 2187 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1775 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2188 | 1776 | return TRUE; |
| 2189 | 1777 | |
| 2190 | 1778 | case 0x3d: /* SDC1 - MIPS III */ |
| 2191 | 1779 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2192 | 1780 | UML_DMOV(block, I1, FPR64(RTREG)); // dmov i1,<cpr1_rt> |
| 2193 | | UML_CALLH(block, *mips3->impstate->write64[mips3->impstate->mode >> 1]); // callh write64 |
| 1781 | UML_CALLH(block, *m_write64[m_core->mode >> 1]); // callh write64 |
| 2194 | 1782 | if (!in_delay_slot) |
| 2195 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1783 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2196 | 1784 | return TRUE; |
| 2197 | 1785 | |
| 2198 | 1786 | case 0x3a: /* SWC2 - MIPS I */ |
| 2199 | 1787 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2200 | 1788 | UML_MOV(block, I1, CPR232(RTREG)); // mov i1,<cpr2_rt> |
| 2201 | | UML_CALLH(block, *mips3->impstate->write32[mips3->impstate->mode >> 1]); // callh write32 |
| 1789 | UML_CALLH(block, *m_write32[m_core->mode >> 1]); // callh write32 |
| 2202 | 1790 | if (!in_delay_slot) |
| 2203 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1791 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2204 | 1792 | return TRUE; |
| 2205 | 1793 | |
| 2206 | 1794 | case 0x3e: /* SDC2 - MIPS II */ |
| 2207 | 1795 | UML_ADD(block, I0, R32(RSREG), SIMMVAL); // add i0,<rsreg>,SIMMVAL |
| 2208 | 1796 | UML_DMOV(block, I1, CPR264(RTREG)); // dmov i1,<cpr2_rt> |
| 2209 | | UML_CALLH(block, *mips3->impstate->write64[mips3->impstate->mode >> 1]); // callh write64 |
| 1797 | UML_CALLH(block, *m_write64[m_core->mode >> 1]); // callh write64 |
| 2210 | 1798 | if (!in_delay_slot) |
| 2211 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 1799 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2212 | 1800 | return TRUE; |
| 2213 | 1801 | |
| 2214 | 1802 | |
| r30757 | r30758 | |
| 2222 | 1810 | /* ----- coprocessor instructions ----- */ |
| 2223 | 1811 | |
| 2224 | 1812 | case 0x10: /* COP0 - MIPS I */ |
| 2225 | | return generate_cop0(mips3, block, compiler, desc); |
| 1813 | return generate_cop0(block, compiler, desc); |
| 2226 | 1814 | |
| 2227 | 1815 | case 0x11: /* COP1 - MIPS I */ |
| 2228 | | return generate_cop1(mips3, block, compiler, desc); |
| 1816 | return generate_cop1(block, compiler, desc); |
| 2229 | 1817 | |
| 2230 | 1818 | case 0x13: /* COP1X - MIPS IV */ |
| 2231 | | return generate_cop1x(mips3, block, compiler, desc); |
| 1819 | return generate_cop1x(block, compiler, desc); |
| 2232 | 1820 | |
| 2233 | 1821 | case 0x12: /* COP2 - MIPS I */ |
| 2234 | | UML_EXH(block, *mips3->impstate->exception[EXCEPTION_INVALIDOP], 0);// exh invalidop,0 |
| 1822 | UML_EXH(block, *m_exception[EXCEPTION_INVALIDOP], 0);// exh invalidop,0 |
| 2235 | 1823 | return TRUE; |
| 2236 | 1824 | |
| 2237 | 1825 | |
| r30757 | r30758 | |
| 2249 | 1837 | 'SPECIAL' group |
| 2250 | 1838 | -------------------------------------------------*/ |
| 2251 | 1839 | |
| 2252 | | static int generate_special(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 1840 | int mips3_device::generate_special(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2253 | 1841 | { |
| 2254 | 1842 | UINT32 op = desc->opptr.l[0]; |
| 2255 | 1843 | UINT8 opswitch = op & 63; |
| r30757 | r30758 | |
| 2355 | 1943 | /* ----- basic arithmetic ----- */ |
| 2356 | 1944 | |
| 2357 | 1945 | case 0x20: /* ADD - MIPS I */ |
| 2358 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1946 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 2359 | 1947 | { |
| 2360 | 1948 | UML_ADD(block, I0, R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 2361 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 1949 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 2362 | 1950 | // exh overflow,0,V |
| 2363 | 1951 | if (RDREG != 0) |
| 2364 | 1952 | UML_DSEXT(block, R64(RDREG), I0, SIZE_DWORD); // dsext <rdreg>,i0,dword |
| r30757 | r30758 | |
| 2379 | 1967 | return TRUE; |
| 2380 | 1968 | |
| 2381 | 1969 | case 0x2c: /* DADD - MIPS III */ |
| 2382 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1970 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 2383 | 1971 | { |
| 2384 | 1972 | UML_DADD(block, I0, R64(RSREG), R64(RTREG)); // dadd i0,<rsreg>,<rtreg> |
| 2385 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 1973 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 2386 | 1974 | // exh overflow,0,V |
| 2387 | 1975 | if (RDREG != 0) |
| 2388 | 1976 | UML_DMOV(block, R64(RDREG), I0); // dmov <rdreg>,i0 |
| r30757 | r30758 | |
| 2397 | 1985 | return TRUE; |
| 2398 | 1986 | |
| 2399 | 1987 | case 0x22: /* SUB - MIPS I */ |
| 2400 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 1988 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 2401 | 1989 | { |
| 2402 | 1990 | UML_SUB(block, I0, R32(RSREG), R32(RTREG)); // sub i0,<rsreg>,<rtreg> |
| 2403 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 1991 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 2404 | 1992 | // exh overflow,0,V |
| 2405 | 1993 | if (RDREG != 0) |
| 2406 | 1994 | UML_DSEXT(block, R64(RDREG), I0, SIZE_DWORD); // dsext <rdreg>,i0,dword |
| r30757 | r30758 | |
| 2421 | 2009 | return TRUE; |
| 2422 | 2010 | |
| 2423 | 2011 | case 0x2e: /* DSUB - MIPS III */ |
| 2424 | | if (mips3->impstate->drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 2012 | if (m_drcoptions & MIPS3DRC_CHECK_OVERFLOWS) |
| 2425 | 2013 | { |
| 2426 | 2014 | UML_DSUB(block, I0, R64(RSREG), R64(RTREG)); // dsub i0,<rsreg>,<rtreg> |
| 2427 | | UML_EXHc(block, COND_V, *mips3->impstate->exception[EXCEPTION_OVERFLOW], 0); |
| 2015 | UML_EXHc(block, COND_V, *m_exception[EXCEPTION_OVERFLOW], 0); |
| 2428 | 2016 | // exh overflow,0,V |
| 2429 | 2017 | if (RDREG != 0) |
| 2430 | 2018 | UML_DMOV(block, R64(RDREG), I0); // dmov <rdreg>,i0 |
| r30757 | r30758 | |
| 2528 | 2116 | |
| 2529 | 2117 | case 0x30: /* TGE - MIPS II */ |
| 2530 | 2118 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2531 | | UML_EXHc(block, COND_GE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,GE |
| 2119 | UML_EXHc(block, COND_GE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,GE |
| 2532 | 2120 | return TRUE; |
| 2533 | 2121 | |
| 2534 | 2122 | case 0x31: /* TGEU - MIPS II */ |
| 2535 | 2123 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2536 | | UML_EXHc(block, COND_AE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,AE |
| 2124 | UML_EXHc(block, COND_AE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,AE |
| 2537 | 2125 | return TRUE; |
| 2538 | 2126 | |
| 2539 | 2127 | case 0x32: /* TLT - MIPS II */ |
| 2540 | 2128 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2541 | | UML_EXHc(block, COND_L, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,LT |
| 2129 | UML_EXHc(block, COND_L, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,LT |
| 2542 | 2130 | return TRUE; |
| 2543 | 2131 | |
| 2544 | 2132 | case 0x33: /* TLTU - MIPS II */ |
| 2545 | 2133 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2546 | | UML_EXHc(block, COND_B, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,B |
| 2134 | UML_EXHc(block, COND_B, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,B |
| 2547 | 2135 | return TRUE; |
| 2548 | 2136 | |
| 2549 | 2137 | case 0x34: /* TEQ - MIPS II */ |
| 2550 | 2138 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2551 | | UML_EXHc(block, COND_E, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,E |
| 2139 | UML_EXHc(block, COND_E, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,E |
| 2552 | 2140 | return TRUE; |
| 2553 | 2141 | |
| 2554 | 2142 | case 0x36: /* TNE - MIPS II */ |
| 2555 | 2143 | UML_DCMP(block, R64(RSREG), R64(RTREG)); // dcmp <rsreg>,<rtreg> |
| 2556 | | UML_EXHc(block, COND_NE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,NE |
| 2144 | UML_EXHc(block, COND_NE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,NE |
| 2557 | 2145 | return TRUE; |
| 2558 | 2146 | |
| 2559 | 2147 | |
| r30757 | r30758 | |
| 2588 | 2176 | /* ----- jumps and branches ----- */ |
| 2589 | 2177 | |
| 2590 | 2178 | case 0x08: /* JR - MIPS I */ |
| 2591 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0); // <next instruction + hashjmp> |
| 2179 | generate_delay_slot_and_branch(block, compiler, desc, 0); // <next instruction + hashjmp> |
| 2592 | 2180 | return TRUE; |
| 2593 | 2181 | |
| 2594 | 2182 | case 0x09: /* JALR - MIPS I */ |
| 2595 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, RDREG); // <next instruction + hashjmp> |
| 2183 | generate_delay_slot_and_branch(block, compiler, desc, RDREG); // <next instruction + hashjmp> |
| 2596 | 2184 | return TRUE; |
| 2597 | 2185 | |
| 2598 | 2186 | |
| 2599 | 2187 | /* ----- system calls ----- */ |
| 2600 | 2188 | |
| 2601 | 2189 | case 0x0c: /* SYSCALL - MIPS I */ |
| 2602 | | UML_EXH(block, *mips3->impstate->exception[EXCEPTION_SYSCALL], 0); // exh syscall,0 |
| 2190 | UML_EXH(block, *m_exception[EXCEPTION_SYSCALL], 0); // exh syscall,0 |
| 2603 | 2191 | return TRUE; |
| 2604 | 2192 | |
| 2605 | 2193 | case 0x0d: /* BREAK - MIPS I */ |
| 2606 | | UML_EXH(block, *mips3->impstate->exception[EXCEPTION_BREAK], 0); // exh break,0 |
| 2194 | UML_EXH(block, *m_exception[EXCEPTION_BREAK], 0); // exh break,0 |
| 2607 | 2195 | return TRUE; |
| 2608 | 2196 | |
| 2609 | 2197 | |
| r30757 | r30758 | |
| 2642 | 2230 | 'REGIMM' group |
| 2643 | 2231 | -------------------------------------------------*/ |
| 2644 | 2232 | |
| 2645 | | static int generate_regimm(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2233 | int mips3_device::generate_regimm(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2646 | 2234 | { |
| 2647 | 2235 | UINT32 op = desc->opptr.l[0]; |
| 2648 | 2236 | UINT8 opswitch = RTREG; |
| r30757 | r30758 | |
| 2658 | 2246 | { |
| 2659 | 2247 | UML_DCMP(block, R64(RSREG), 0); // dcmp <rsreg>,0 |
| 2660 | 2248 | UML_JMPc(block, COND_GE, skip = compiler->labelnum++); // jmp skip,GE |
| 2661 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2249 | generate_delay_slot_and_branch(block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2662 | 2250 | // <next instruction + hashjmp> |
| 2663 | 2251 | UML_LABEL(block, skip); // skip: |
| 2664 | 2252 | } |
| r30757 | r30758 | |
| 2672 | 2260 | { |
| 2673 | 2261 | UML_DCMP(block, R64(RSREG), 0); // dcmp <rsreg>,0 |
| 2674 | 2262 | UML_JMPc(block, COND_L, skip = compiler->labelnum++); // jmp skip,L |
| 2675 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2263 | generate_delay_slot_and_branch(block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2676 | 2264 | // <next instruction + hashjmp> |
| 2677 | 2265 | UML_LABEL(block, skip); // skip: |
| 2678 | 2266 | } |
| 2679 | 2267 | else |
| 2680 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2268 | generate_delay_slot_and_branch(block, compiler, desc, (opswitch & 0x10) ? 31 : 0); |
| 2681 | 2269 | // <next instruction + hashjmp> |
| 2682 | 2270 | return TRUE; |
| 2683 | 2271 | |
| 2684 | 2272 | case 0x08: /* TGEI */ |
| 2685 | 2273 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2686 | | UML_EXHc(block, COND_GE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,GE |
| 2274 | UML_EXHc(block, COND_GE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,GE |
| 2687 | 2275 | return TRUE; |
| 2688 | 2276 | |
| 2689 | 2277 | case 0x09: /* TGEIU */ |
| 2690 | 2278 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2691 | | UML_EXHc(block, COND_AE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,AE |
| 2279 | UML_EXHc(block, COND_AE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,AE |
| 2692 | 2280 | return TRUE; |
| 2693 | 2281 | |
| 2694 | 2282 | case 0x0a: /* TLTI */ |
| 2695 | 2283 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2696 | | UML_EXHc(block, COND_L, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,L |
| 2284 | UML_EXHc(block, COND_L, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,L |
| 2697 | 2285 | return TRUE; |
| 2698 | 2286 | |
| 2699 | 2287 | case 0x0b: /* TLTIU */ |
| 2700 | 2288 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2701 | | UML_EXHc(block, COND_B, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,B |
| 2289 | UML_EXHc(block, COND_B, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,B |
| 2702 | 2290 | return TRUE; |
| 2703 | 2291 | |
| 2704 | 2292 | case 0x0c: /* TEQI */ |
| 2705 | 2293 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2706 | | UML_EXHc(block, COND_E, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,E |
| 2294 | UML_EXHc(block, COND_E, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,E |
| 2707 | 2295 | return TRUE; |
| 2708 | 2296 | |
| 2709 | 2297 | case 0x0e: /* TNEI */ |
| 2710 | 2298 | UML_DCMP(block, R64(RSREG), SIMMVAL); // dcmp <rsreg>,SIMMVAL |
| 2711 | | UML_EXHc(block, COND_NE, *mips3->impstate->exception[EXCEPTION_TRAP], 0);// exh trap,0,NE |
| 2299 | UML_EXHc(block, COND_NE, *m_exception[EXCEPTION_TRAP], 0);// exh trap,0,NE |
| 2712 | 2300 | return TRUE; |
| 2713 | 2301 | } |
| 2714 | 2302 | return FALSE; |
| r30757 | r30758 | |
| 2720 | 2308 | specific group |
| 2721 | 2309 | -------------------------------------------------*/ |
| 2722 | 2310 | |
| 2723 | | static int generate_idt(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2311 | int mips3_device::generate_idt(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2724 | 2312 | { |
| 2725 | 2313 | UINT32 op = desc->opptr.l[0]; |
| 2726 | 2314 | UINT8 opswitch = op & 0x1f; |
| 2727 | 2315 | |
| 2728 | 2316 | /* only enabled on IDT processors */ |
| 2729 | | if (mips3->flavor != MIPS3_TYPE_R4650) |
| 2317 | if (m_flavor != MIPS3_TYPE_R4650) |
| 2730 | 2318 | return FALSE; |
| 2731 | 2319 | |
| 2732 | 2320 | switch (opswitch) |
| r30757 | r30758 | |
| 2770 | 2358 | handle special COP0 registers |
| 2771 | 2359 | -------------------------------------------------*/ |
| 2772 | 2360 | |
| 2773 | | static int generate_set_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) |
| 2361 | int mips3_device::generate_set_cop0_reg(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) |
| 2774 | 2362 | { |
| 2775 | 2363 | int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0); |
| 2776 | 2364 | code_label link; |
| r30757 | r30758 | |
| 2781 | 2369 | UML_ROLINS(block, CPR032(COP0_Cause), I0, 0, ~0xfc00); // rolins [Cause],i0,0,~0xfc00 |
| 2782 | 2370 | compiler->checksoftints = TRUE; |
| 2783 | 2371 | if (!in_delay_slot) |
| 2784 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 2372 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2785 | 2373 | return TRUE; |
| 2786 | 2374 | |
| 2787 | 2375 | case COP0_Status: |
| 2788 | | generate_update_cycles(mips3, block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2376 | generate_update_cycles(block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2789 | 2377 | UML_MOV(block, I1, CPR032(COP0_Status)); // mov i1,[Status] |
| 2790 | 2378 | UML_MOV(block, CPR032(COP0_Status), I0); // mov [Status],i0 |
| 2791 | | generate_update_mode(mips3, block); // <update mode> |
| 2379 | generate_update_mode(block); // <update mode> |
| 2792 | 2380 | UML_XOR(block, I0, I0, I1); // xor i0,i0,i1 |
| 2793 | 2381 | UML_TEST(block, I0, 0x8000); // test i0,0x8000 |
| 2794 | | UML_CALLCc(block, COND_NZ, (c_function)mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core,NZ |
| 2382 | UML_CALLCc(block, COND_NZ, cfunc_mips3com_update_cycle_counting, this); // callc mips3com_update_cycle_counting,mips.core,NZ |
| 2795 | 2383 | compiler->checkints = TRUE; |
| 2796 | 2384 | if (!in_delay_slot) |
| 2797 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 2385 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 2798 | 2386 | return TRUE; |
| 2799 | 2387 | |
| 2800 | 2388 | case COP0_Count: |
| 2801 | | generate_update_cycles(mips3, block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2389 | generate_update_cycles(block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2802 | 2390 | UML_MOV(block, CPR032(COP0_Count), I0); // mov [Count],i0 |
| 2803 | | UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 |
| 2391 | UML_CALLC(block, cfunc_get_cycles, this); // callc cfunc_get_cycles,mips3 |
| 2804 | 2392 | UML_DAND(block, I0, I0, 0xffffffff); // and i0,i0,0xffffffff |
| 2805 | 2393 | UML_DADD(block, I0, I0, I0); // dadd i0,i0,i0 |
| 2806 | | UML_DSUB(block, mem(&mips3->count_zero_time), mem(&mips3->impstate->numcycles), I0); |
| 2807 | | // dsub [count_zero_time],[mips3->impstate->numcycles],i0 |
| 2808 | | UML_CALLC(block, (c_function)mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core |
| 2394 | UML_DSUB(block, mem(&m_core->count_zero_time), mem(&m_core->numcycles), I0); |
| 2395 | // dsub [count_zero_time],[m_numcycles],i0 |
| 2396 | UML_CALLC(block, cfunc_mips3com_update_cycle_counting, this); // callc mips3com_update_cycle_counting,mips.core |
| 2809 | 2397 | return TRUE; |
| 2810 | 2398 | |
| 2811 | 2399 | case COP0_Compare: |
| 2812 | | UML_MOV(block, mem(&mips3->compare_armed), 1); // mov [compare_armed],1 |
| 2813 | | generate_update_cycles(mips3, block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2400 | UML_MOV(block, mem(&m_core->compare_armed), 1); // mov [compare_armed],1 |
| 2401 | generate_update_cycles(block, compiler, desc->pc, !in_delay_slot); // <subtract cycles> |
| 2814 | 2402 | UML_MOV(block, CPR032(COP0_Compare), I0); // mov [Compare],i0 |
| 2815 | 2403 | UML_AND(block, CPR032(COP0_Cause), CPR032(COP0_Cause), ~0x8000); // and [Cause],[Cause],~0x8000 |
| 2816 | | UML_CALLC(block, (c_function)mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core |
| 2404 | UML_CALLC(block, cfunc_mips3com_update_cycle_counting, this); // callc mips3com_update_cycle_counting,mips.core |
| 2817 | 2405 | return TRUE; |
| 2818 | 2406 | |
| 2819 | 2407 | case COP0_PRId: |
| r30757 | r30758 | |
| 2828 | 2416 | UML_MOV(block, CPR032(reg), I0); // mov cpr0[reg],i0 |
| 2829 | 2417 | UML_TEST(block, I1, 0xff); // test i1,0xff |
| 2830 | 2418 | UML_JMPc(block, COND_Z, link = compiler->labelnum++); // jmp link,z |
| 2831 | | UML_CALLC(block, (c_function)mips3com_asid_changed, mips3); // callc mips3com_asid_changed |
| 2419 | UML_CALLC(block, cfunc_mips3com_asid_changed, this); // callc mips3com_asid_changed |
| 2832 | 2420 | UML_LABEL(block, link); // link: |
| 2833 | 2421 | return TRUE; |
| 2834 | 2422 | |
| r30757 | r30758 | |
| 2844 | 2432 | read special COP0 registers |
| 2845 | 2433 | -------------------------------------------------*/ |
| 2846 | 2434 | |
| 2847 | | static int generate_get_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) |
| 2435 | int mips3_device::generate_get_cop0_reg(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) |
| 2848 | 2436 | { |
| 2849 | 2437 | code_label link1, link2; |
| 2850 | 2438 | |
| 2851 | 2439 | switch (reg) |
| 2852 | 2440 | { |
| 2853 | 2441 | case COP0_Count: |
| 2854 | | generate_update_cycles(mips3, block, compiler, desc->pc, FALSE); // <subtract cycles> |
| 2855 | | UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 |
| 2856 | | UML_DSUB(block, I0, mem(&mips3->impstate->numcycles), mem(&mips3->count_zero_time)); |
| 2442 | generate_update_cycles(block, compiler, desc->pc, FALSE); // <subtract cycles> |
| 2443 | UML_CALLC(block, cfunc_get_cycles, this); // callc cfunc_get_cycles,mips3 |
| 2444 | UML_DSUB(block, I0, mem(&m_core->numcycles), mem(&m_core->count_zero_time)); |
| 2857 | 2445 | // dsub i0,[numcycles],[count_zero_time] |
| 2858 | 2446 | UML_DSHR(block, I0, I0, 1); // dshr i0,i0,1 |
| 2859 | 2447 | UML_DSEXT(block, I0, I0, SIZE_DWORD); // dsext i0,i0,dword |
| 2860 | 2448 | return TRUE; |
| 2861 | 2449 | |
| 2862 | 2450 | case COP0_Random: |
| 2863 | | generate_update_cycles(mips3, block, compiler, desc->pc, FALSE); // <subtract cycles> |
| 2864 | | UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 |
| 2865 | | UML_DSUB(block, I0, mem(&mips3->impstate->numcycles), mem(&mips3->count_zero_time)); |
| 2451 | generate_update_cycles(block, compiler, desc->pc, FALSE); // <subtract cycles> |
| 2452 | UML_CALLC(block, cfunc_get_cycles, this); // callc cfunc_get_cycles,mips3 |
| 2453 | UML_DSUB(block, I0, mem(&m_core->numcycles), mem(&m_core->count_zero_time)); |
| 2866 | 2454 | // dsub i0,[numcycles],[count_zero_time] |
| 2867 | 2455 | UML_AND(block, I1, CPR032(COP0_Wired), 0x3f); // and i1,[Wired],0x3f |
| 2868 | 2456 | UML_SUB(block, I2, 48, I1); // sub i2,48,i1 |
| r30757 | r30758 | |
| 2888 | 2476 | generate_cop0 - compile COP0 opcodes |
| 2889 | 2477 | -------------------------------------------------*/ |
| 2890 | 2478 | |
| 2891 | | static int generate_cop0(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2479 | int mips3_device::generate_cop0(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2892 | 2480 | { |
| 2893 | 2481 | UINT32 op = desc->opptr.l[0]; |
| 2894 | 2482 | UINT8 opswitch = RSREG; |
| 2895 | 2483 | int skip; |
| 2896 | 2484 | |
| 2897 | 2485 | /* generate an exception if COP0 is disabled unless we are in kernel mode */ |
| 2898 | | if ((mips3->impstate->mode >> 1) != MODE_KERNEL) |
| 2486 | if ((m_core->mode >> 1) != MODE_KERNEL) |
| 2899 | 2487 | { |
| 2900 | 2488 | UML_TEST(block, CPR032(COP0_Status), SR_COP0); // test [Status],SR_COP0 |
| 2901 | | UML_EXHc(block, COND_Z, *mips3->impstate->exception[EXCEPTION_BADCOP], 0);// exh cop,0,Z |
| 2489 | UML_EXHc(block, COND_Z, *m_exception[EXCEPTION_BADCOP], 0);// exh cop,0,Z |
| 2902 | 2490 | } |
| 2903 | 2491 | |
| 2904 | 2492 | switch (opswitch) |
| r30757 | r30758 | |
| 2906 | 2494 | case 0x00: /* MFCz */ |
| 2907 | 2495 | if (RTREG != 0) |
| 2908 | 2496 | { |
| 2909 | | generate_get_cop0_reg(mips3, block, compiler, desc, RDREG); // <get cop0 reg> |
| 2497 | generate_get_cop0_reg(block, compiler, desc, RDREG); // <get cop0 reg> |
| 2910 | 2498 | UML_DSEXT(block, R64(RTREG), I0, SIZE_DWORD); // dsext <rtreg>,i0,dword |
| 2911 | 2499 | } |
| 2912 | 2500 | return TRUE; |
| r30757 | r30758 | |
| 2914 | 2502 | case 0x01: /* DMFCz */ |
| 2915 | 2503 | if (RTREG != 0) |
| 2916 | 2504 | { |
| 2917 | | generate_get_cop0_reg(mips3, block, compiler, desc, RDREG); // <get cop0 reg> |
| 2505 | generate_get_cop0_reg(block, compiler, desc, RDREG); // <get cop0 reg> |
| 2918 | 2506 | UML_DMOV(block, R64(RTREG), I0); // dmov <rtreg>,i0 |
| 2919 | 2507 | } |
| 2920 | 2508 | return TRUE; |
| r30757 | r30758 | |
| 2926 | 2514 | |
| 2927 | 2515 | case 0x04: /* MTCz */ |
| 2928 | 2516 | UML_DSEXT(block, I0, R32(RTREG), SIZE_DWORD); // dsext i0,<rtreg>,dword |
| 2929 | | generate_set_cop0_reg(mips3, block, compiler, desc, RDREG); // <set cop0 reg> |
| 2517 | generate_set_cop0_reg(block, compiler, desc, RDREG); // <set cop0 reg> |
| 2930 | 2518 | return TRUE; |
| 2931 | 2519 | |
| 2932 | 2520 | case 0x05: /* DMTCz */ |
| 2933 | 2521 | UML_DMOV(block, I0, R64(RTREG)); // dmov i0,<rtreg> |
| 2934 | | generate_set_cop0_reg(mips3, block, compiler, desc, RDREG); // <set cop0 reg> |
| 2522 | generate_set_cop0_reg(block, compiler, desc, RDREG); // <set cop0 reg> |
| 2935 | 2523 | return TRUE; |
| 2936 | 2524 | |
| 2937 | 2525 | case 0x06: /* CTCz */ |
| r30757 | r30758 | |
| 2957 | 2545 | switch (op & 0x01ffffff) |
| 2958 | 2546 | { |
| 2959 | 2547 | case 0x01: /* TLBR */ |
| 2960 | | UML_CALLC(block, (c_function)mips3com_tlbr, mips3); // callc mips3com_tlbr,mips3 |
| 2548 | UML_CALLC(block, cfunc_mips3com_tlbr, this); // callc mips3com_tlbr,mips3 |
| 2961 | 2549 | return TRUE; |
| 2962 | 2550 | |
| 2963 | 2551 | case 0x02: /* TLBWI */ |
| 2964 | | UML_CALLC(block, (c_function)mips3com_tlbwi, mips3); // callc mips3com_tlbwi,mips3 |
| 2552 | UML_CALLC(block, cfunc_mips3com_tlbwi, this); // callc mips3com_tlbwi,mips3 |
| 2965 | 2553 | return TRUE; |
| 2966 | 2554 | |
| 2967 | 2555 | case 0x06: /* TLBWR */ |
| 2968 | | UML_CALLC(block, (c_function)mips3com_tlbwr, mips3); // callc mips3com_tlbwr,mips3 |
| 2556 | UML_CALLC(block, cfunc_mips3com_tlbwr, this); // callc mips3com_tlbwr,mips3 |
| 2969 | 2557 | return TRUE; |
| 2970 | 2558 | |
| 2971 | 2559 | case 0x08: /* TLBP */ |
| 2972 | | UML_CALLC(block, (c_function)mips3com_tlbp, mips3); // callc mips3com_tlbp,mips3 |
| 2560 | UML_CALLC(block, cfunc_mips3com_tlbp, this); // callc mips3com_tlbp,mips3 |
| 2973 | 2561 | return TRUE; |
| 2974 | 2562 | |
| 2975 | 2563 | case 0x18: /* ERET */ |
| 2976 | | UML_MOV(block, mem(&mips3->llbit), 0); // mov [llbit],0 |
| 2564 | UML_MOV(block, mem(&m_core->llbit), 0); // mov [llbit],0 |
| 2977 | 2565 | UML_MOV(block, I0, CPR032(COP0_Status)); // mov i0,[Status] |
| 2978 | 2566 | UML_TEST(block, I0, SR_ERL); // test i0,SR_ERL |
| 2979 | 2567 | UML_JMPc(block, COND_NZ, skip = compiler->labelnum++); // jmp skip,nz |
| 2980 | 2568 | UML_AND(block, I0, I0, ~SR_EXL); // and i0,i0,~SR_EXL |
| 2981 | 2569 | UML_MOV(block, CPR032(COP0_Status), I0); // mov [Status],i0 |
| 2982 | | generate_update_mode(mips3, block); |
| 2570 | generate_update_mode(block); |
| 2983 | 2571 | compiler->checkints = TRUE; |
| 2984 | | generate_update_cycles(mips3, block, compiler, CPR032(COP0_EPC), TRUE);// <subtract cycles> |
| 2985 | | UML_HASHJMP(block, mem(&mips3->impstate->mode), CPR032(COP0_EPC), *mips3->impstate->nocode); |
| 2572 | generate_update_cycles(block, compiler, CPR032(COP0_EPC), TRUE);// <subtract cycles> |
| 2573 | UML_HASHJMP(block, mem(&m_core->mode), CPR032(COP0_EPC), *m_nocode); |
| 2986 | 2574 | // hashjmp <mode>,[EPC],nocode |
| 2987 | 2575 | UML_LABEL(block, skip); // skip: |
| 2988 | 2576 | UML_AND(block, I0, I0, ~SR_ERL); // and i0,i0,~SR_ERL |
| 2989 | 2577 | UML_MOV(block, CPR032(COP0_Status), I0); // mov [Status],i0 |
| 2990 | | generate_update_mode(mips3, block); |
| 2578 | generate_update_mode(block); |
| 2991 | 2579 | compiler->checkints = TRUE; |
| 2992 | | generate_update_cycles(mips3, block, compiler, CPR032(COP0_ErrorPC), TRUE); |
| 2580 | generate_update_cycles(block, compiler, CPR032(COP0_ErrorPC), TRUE); |
| 2993 | 2581 | // <subtract cycles> |
| 2994 | | UML_HASHJMP(block, mem(&mips3->impstate->mode), CPR032(COP0_ErrorPC), *mips3->impstate->nocode); |
| 2582 | UML_HASHJMP(block, mem(&m_core->mode), CPR032(COP0_ErrorPC), *m_nocode); |
| 2995 | 2583 | // hashjmp <mode>,[EPC],nocode |
| 2996 | 2584 | return TRUE; |
| 2997 | 2585 | |
| r30757 | r30758 | |
| 3014 | 2602 | generate_cop1 - compile COP1 opcodes |
| 3015 | 2603 | -------------------------------------------------*/ |
| 3016 | 2604 | |
| 3017 | | static int generate_cop1(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2605 | int mips3_device::generate_cop1(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 3018 | 2606 | { |
| 3019 | 2607 | UINT32 op = desc->opptr.l[0]; |
| 3020 | 2608 | code_label skip; |
| 3021 | 2609 | condition_t condition; |
| 3022 | 2610 | |
| 3023 | 2611 | /* generate an exception if COP1 is disabled */ |
| 3024 | | if (mips3->impstate->drcoptions & MIPS3DRC_STRICT_COP1) |
| 2612 | if (m_drcoptions & MIPS3DRC_STRICT_COP1) |
| 3025 | 2613 | { |
| 3026 | 2614 | UML_TEST(block, CPR032(COP0_Status), SR_COP1); // test [Status],SR_COP1 |
| 3027 | | UML_EXHc(block, COND_Z, *mips3->impstate->exception[EXCEPTION_BADCOP], 1);// exh cop,1,Z |
| 2615 | UML_EXHc(block, COND_Z, *m_exception[EXCEPTION_BADCOP], 1);// exh cop,1,Z |
| 3028 | 2616 | } |
| 3029 | 2617 | |
| 3030 | 2618 | switch (RSREG) |
| r30757 | r30758 | |
| 3062 | 2650 | UML_TEST(block, I0, 3); // test i0,3 |
| 3063 | 2651 | UML_JMPc(block, COND_Z, skip = compiler->labelnum++); // jmp skip,Z |
| 3064 | 2652 | UML_AND(block, I0, CCR132(31), 3); // and i0,ccr1[31],3 |
| 3065 | | UML_LOAD(block, I0, &mips3->impstate->fpmode[0], I0, SIZE_BYTE, SCALE_x1);// load i0,fpmode,i0,byte |
| 2653 | UML_LOAD(block, I0, &m_fpmode[0], I0, SIZE_BYTE, SCALE_x1);// load i0,fpmode,i0,byte |
| 3066 | 2654 | UML_SETFMOD(block, I0); // setfmod i0 |
| 3067 | 2655 | UML_LABEL(block, skip); // skip: |
| 3068 | 2656 | } |
| r30757 | r30758 | |
| 3075 | 2663 | case 0x02: /* BCzFL - MIPS II */ |
| 3076 | 2664 | UML_TEST(block, CCR132(31), FCCMASK(op >> 18)); // test ccr1[31],fccmask[which] |
| 3077 | 2665 | UML_JMPc(block, COND_NZ, skip = compiler->labelnum++); // jmp skip,NZ |
| 3078 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0);// <next instruction + hashjmp> |
| 2666 | generate_delay_slot_and_branch(block, compiler, desc, 0);// <next instruction + hashjmp> |
| 3079 | 2667 | UML_LABEL(block, skip); // skip: |
| 3080 | 2668 | return TRUE; |
| 3081 | 2669 | |
| r30757 | r30758 | |
| 3083 | 2671 | case 0x03: /* BCzTL - MIPS II */ |
| 3084 | 2672 | UML_TEST(block, CCR132(31), FCCMASK(op >> 18)); // test ccr1[31],fccmask[which] |
| 3085 | 2673 | UML_JMPc(block, COND_Z, skip = compiler->labelnum++); // jmp skip,Z |
| 3086 | | generate_delay_slot_and_branch(mips3, block, compiler, desc, 0);// <next instruction + hashjmp> |
| 2674 | generate_delay_slot_and_branch(block, compiler, desc, 0);// <next instruction + hashjmp> |
| 3087 | 2675 | UML_LABEL(block, skip); // skip: |
| 3088 | 2676 | return TRUE; |
| 3089 | 2677 | } |
| r30757 | r30758 | |
| 3390 | 2978 | generate_cop1x - compile COP1X opcodes |
| 3391 | 2979 | -------------------------------------------------*/ |
| 3392 | 2980 | |
| 3393 | | static int generate_cop1x(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2981 | int mips3_device::generate_cop1x(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 3394 | 2982 | { |
| 3395 | 2983 | int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0); |
| 3396 | 2984 | UINT32 op = desc->opptr.l[0]; |
| 3397 | 2985 | |
| 3398 | | if (mips3->impstate->drcoptions & MIPS3DRC_STRICT_COP1) |
| 2986 | if (m_drcoptions & MIPS3DRC_STRICT_COP1) |
| 3399 | 2987 | { |
| 3400 | 2988 | UML_TEST(block, CPR032(COP0_Status), SR_COP1); // test [Status],SR_COP1 |
| 3401 | | UML_EXHc(block, COND_Z, *mips3->impstate->exception[EXCEPTION_BADCOP], 1);// exh cop,1,Z |
| 2989 | UML_EXHc(block, COND_Z, *m_exception[EXCEPTION_BADCOP], 1);// exh cop,1,Z |
| 3402 | 2990 | } |
| 3403 | 2991 | |
| 3404 | 2992 | switch (op & 0x3f) |
| 3405 | 2993 | { |
| 3406 | 2994 | case 0x00: /* LWXC1 - MIPS IV */ |
| 3407 | 2995 | UML_ADD(block, I0, R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3408 | | UML_CALLH(block, *mips3->impstate->read32[mips3->impstate->mode >> 1]); // callh read32 |
| 2996 | UML_CALLH(block, *m_read32[m_core->mode >> 1]); // callh read32 |
| 3409 | 2997 | UML_MOV(block, FPR32(FDREG), I0); // mov <cpr1_fd>,i0 |
| 3410 | 2998 | if (!in_delay_slot) |
| 3411 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 2999 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 3412 | 3000 | return TRUE; |
| 3413 | 3001 | |
| 3414 | 3002 | case 0x01: /* LDXC1 - MIPS IV */ |
| 3415 | 3003 | UML_ADD(block, I0, R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3416 | | UML_CALLH(block, *mips3->impstate->read64[mips3->impstate->mode >> 1]); // callh read64 |
| 3004 | UML_CALLH(block, *m_read64[m_core->mode >> 1]); // callh read64 |
| 3417 | 3005 | UML_DMOV(block, FPR64(FDREG), I0); // dmov <cpr1_fd>,i0 |
| 3418 | 3006 | if (!in_delay_slot) |
| 3419 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 3007 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 3420 | 3008 | return TRUE; |
| 3421 | 3009 | |
| 3422 | 3010 | case 0x08: /* SWXC1 - MIPS IV */ |
| 3423 | 3011 | UML_ADD(block, I0, R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3424 | 3012 | UML_MOV(block, I1, FPR32(FSREG)); // mov i1,<cpr1_fs> |
| 3425 | | UML_CALLH(block, *mips3->impstate->write32[mips3->impstate->mode >> 1]); // callh write32 |
| 3013 | UML_CALLH(block, *m_write32[m_core->mode >> 1]); // callh write32 |
| 3426 | 3014 | if (!in_delay_slot) |
| 3427 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 3015 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 3428 | 3016 | return TRUE; |
| 3429 | 3017 | |
| 3430 | 3018 | case 0x09: /* SDXC1 - MIPS IV */ |
| 3431 | 3019 | UML_ADD(block, I0, R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3432 | 3020 | UML_DMOV(block, I1, FPR64(FSREG)); // dmov i1,<cpr1_fs> |
| 3433 | | UML_CALLH(block, *mips3->impstate->write64[mips3->impstate->mode >> 1]); // callh write64 |
| 3021 | UML_CALLH(block, *m_write64[m_core->mode >> 1]); // callh write64 |
| 3434 | 3022 | if (!in_delay_slot) |
| 3435 | | generate_update_cycles(mips3, block, compiler, desc->pc + 4, TRUE); |
| 3023 | generate_update_cycles(block, compiler, desc->pc + 4, TRUE); |
| 3436 | 3024 | return TRUE; |
| 3437 | 3025 | |
| 3438 | 3026 | case 0x0f: /* PREFX */ |
| r30757 | r30758 | |
| 3498 | 3086 | including disassembly of a MIPS instruction |
| 3499 | 3087 | -------------------------------------------------*/ |
| 3500 | 3088 | |
| 3501 | | static void log_add_disasm_comment(mips3_state *mips3, drcuml_block *block, UINT32 pc, UINT32 op) |
| 3089 | void mips3_device::log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 op) |
| 3502 | 3090 | { |
| 3503 | 3091 | #if (LOG_UML) |
| 3504 | 3092 | char buffer[100]; |
| r30757 | r30758 | |
| 3514 | 3102 | flags |
| 3515 | 3103 | -------------------------------------------------*/ |
| 3516 | 3104 | |
| 3517 | | static const char *log_desc_flags_to_string(UINT32 flags) |
| 3105 | const char *mips3_device::log_desc_flags_to_string(UINT32 flags) |
| 3518 | 3106 | { |
| 3519 | 3107 | static char tempbuf[30]; |
| 3520 | 3108 | char *dest = tempbuf; |
| r30757 | r30758 | |
| 3568 | 3156 | log_register_list - log a list of GPR registers |
| 3569 | 3157 | -------------------------------------------------*/ |
| 3570 | 3158 | |
| 3571 | | static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist) |
| 3159 | void mips3_device::log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist) |
| 3572 | 3160 | { |
| 3573 | 3161 | int count = 0; |
| 3574 | 3162 | int regnum; |
| r30757 | r30758 | |
| 3622 | 3210 | log_opcode_desc - log a list of descriptions |
| 3623 | 3211 | -------------------------------------------------*/ |
| 3624 | 3212 | |
| 3625 | | static void log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, int indent) |
| 3213 | void mips3_device::log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, int indent) |
| 3626 | 3214 | { |
| 3627 | 3215 | /* open the file, creating it if necessary */ |
| 3628 | 3216 | if (indent == 0) |
| r30757 | r30758 | |
| 3659 | 3247 | } |
| 3660 | 3248 | } |
| 3661 | 3249 | |
| 3662 | | /*************************************************************************** |
| 3663 | | NEC VR4300 VARIANTS |
| 3664 | | ***************************************************************************/ |
| 3665 | | |
| 3666 | | // NEC VR4300 series is MIPS III with 32-bit address bus and slightly custom COP0/TLB |
| 3667 | | static CPU_INIT( vr4300be ) |
| 3668 | | { |
| 3669 | | mips3_init(MIPS3_TYPE_VR4300, TRUE, device, irqcallback); |
| 3670 | | } |
| 3671 | | |
| 3672 | | static CPU_INIT( vr4300le ) |
| 3673 | | { |
| 3674 | | mips3_init(MIPS3_TYPE_VR4300, FALSE, device, irqcallback); |
| 3675 | | } |
| 3676 | | |
| 3677 | | CPU_GET_INFO( vr4300be_drc ) |
| 3678 | | { |
| 3679 | | switch (state) |
| 3680 | | { |
| 3681 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3682 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3683 | | |
| 3684 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3685 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300be); break; |
| 3686 | | |
| 3687 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3688 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4300 (big) DRC"); break; |
| 3689 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4300be_drc"); break; |
| 3690 | | |
| 3691 | | /* --- everything else is handled generically --- */ |
| 3692 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3693 | | } |
| 3694 | | } |
| 3695 | | |
| 3696 | | CPU_GET_INFO( vr4300le_drc ) |
| 3697 | | { |
| 3698 | | switch (state) |
| 3699 | | { |
| 3700 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3701 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3702 | | |
| 3703 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3704 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300le); break; |
| 3705 | | |
| 3706 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3707 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4300 (little) DRC"); break; |
| 3708 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4300le_drc"); break; |
| 3709 | | |
| 3710 | | /* --- everything else is handled generically --- */ |
| 3711 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3712 | | } |
| 3713 | | } |
| 3714 | | |
| 3715 | | // VR4310 = VR4300 with different speed bin |
| 3716 | | CPU_GET_INFO( vr4310be_drc ) |
| 3717 | | { |
| 3718 | | switch (state) |
| 3719 | | { |
| 3720 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3721 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3722 | | |
| 3723 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3724 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300be); break; |
| 3725 | | |
| 3726 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3727 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4310 (big) DRC"); break; |
| 3728 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4310be_drc"); break; |
| 3729 | | |
| 3730 | | /* --- everything else is handled generically --- */ |
| 3731 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3732 | | } |
| 3733 | | } |
| 3734 | | |
| 3735 | | CPU_GET_INFO( vr4310le_drc ) |
| 3736 | | { |
| 3737 | | switch (state) |
| 3738 | | { |
| 3739 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3740 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3741 | | |
| 3742 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3743 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(vr4300le); break; |
| 3744 | | |
| 3745 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3746 | | case CPUINFO_STR_NAME: strcpy(info->s, "VR4310 (little) DRC"); break; |
| 3747 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "vr4310le_drc"); break; |
| 3748 | | |
| 3749 | | /* --- everything else is handled generically --- */ |
| 3750 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3751 | | } |
| 3752 | | } |
| 3753 | | |
| 3754 | | |
| 3755 | | /*************************************************************************** |
| 3756 | | R4600 VARIANTS |
| 3757 | | ***************************************************************************/ |
| 3758 | | |
| 3759 | | static CPU_INIT( r4600be ) |
| 3760 | | { |
| 3761 | | mips3_init(MIPS3_TYPE_R4600, TRUE, device, irqcallback); |
| 3762 | | } |
| 3763 | | |
| 3764 | | static CPU_INIT( r4600le ) |
| 3765 | | { |
| 3766 | | mips3_init(MIPS3_TYPE_R4600, FALSE, device, irqcallback); |
| 3767 | | } |
| 3768 | | |
| 3769 | | CPU_GET_INFO( r4600be_drc ) |
| 3770 | | { |
| 3771 | | switch (state) |
| 3772 | | { |
| 3773 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3774 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3775 | | |
| 3776 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3777 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4600be); break; |
| 3778 | | |
| 3779 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3780 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4600 (big) DRC"); break; |
| 3781 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4600be_drc"); break; |
| 3782 | | |
| 3783 | | /* --- everything else is handled generically --- */ |
| 3784 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3785 | | } |
| 3786 | | } |
| 3787 | | |
| 3788 | | CPU_GET_INFO( r4600le_drc ) |
| 3789 | | { |
| 3790 | | switch (state) |
| 3791 | | { |
| 3792 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3793 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3794 | | |
| 3795 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3796 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4600le); break; |
| 3797 | | |
| 3798 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3799 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4600 (little) DRC"); break; |
| 3800 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4600le_drc"); break; |
| 3801 | | /* --- everything else is handled generically --- */ |
| 3802 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3803 | | } |
| 3804 | | } |
| 3805 | | |
| 3806 | | |
| 3807 | | |
| 3808 | | /*************************************************************************** |
| 3809 | | R4650 VARIANTS |
| 3810 | | ***************************************************************************/ |
| 3811 | | |
| 3812 | | static CPU_INIT( r4650be ) |
| 3813 | | { |
| 3814 | | mips3_init(MIPS3_TYPE_R4650, TRUE, device, irqcallback); |
| 3815 | | } |
| 3816 | | |
| 3817 | | static CPU_INIT( r4650le ) |
| 3818 | | { |
| 3819 | | mips3_init(MIPS3_TYPE_R4650, FALSE, device, irqcallback); |
| 3820 | | } |
| 3821 | | |
| 3822 | | CPU_GET_INFO( r4650be_drc ) |
| 3823 | | { |
| 3824 | | switch (state) |
| 3825 | | { |
| 3826 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3827 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3828 | | |
| 3829 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3830 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4650be); break; |
| 3831 | | |
| 3832 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3833 | | case CPUINFO_STR_NAME: strcpy(info->s, "IDT R4650 (big) DRC"); break; |
| 3834 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4650be_drc"); break; |
| 3835 | | |
| 3836 | | /* --- everything else is handled generically --- */ |
| 3837 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3838 | | } |
| 3839 | | } |
| 3840 | | |
| 3841 | | CPU_GET_INFO( r4650le_drc ) |
| 3842 | | { |
| 3843 | | switch (state) |
| 3844 | | { |
| 3845 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3846 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3847 | | |
| 3848 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3849 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4650le); break; |
| 3850 | | |
| 3851 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3852 | | case CPUINFO_STR_NAME: strcpy(info->s, "IDT R4650 (little) DRC"); break; |
| 3853 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4650le_drc"); break; |
| 3854 | | |
| 3855 | | /* --- everything else is handled generically --- */ |
| 3856 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3857 | | } |
| 3858 | | } |
| 3859 | | |
| 3860 | | |
| 3861 | | |
| 3862 | | /*************************************************************************** |
| 3863 | | R4700 VARIANTS |
| 3864 | | ***************************************************************************/ |
| 3865 | | |
| 3866 | | static CPU_INIT( r4700be ) |
| 3867 | | { |
| 3868 | | mips3_init(MIPS3_TYPE_R4700, TRUE, device, irqcallback); |
| 3869 | | } |
| 3870 | | |
| 3871 | | static CPU_INIT( r4700le ) |
| 3872 | | { |
| 3873 | | mips3_init(MIPS3_TYPE_R4700, FALSE, device, irqcallback); |
| 3874 | | } |
| 3875 | | |
| 3876 | | CPU_GET_INFO( r4700be_drc ) |
| 3877 | | { |
| 3878 | | switch (state) |
| 3879 | | { |
| 3880 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3881 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3882 | | |
| 3883 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3884 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4700be); break; |
| 3885 | | |
| 3886 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3887 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4700 (big) DRC"); break; |
| 3888 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4700be_drc"); break; |
| 3889 | | |
| 3890 | | /* --- everything else is handled generically --- */ |
| 3891 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3892 | | } |
| 3893 | | } |
| 3894 | | |
| 3895 | | CPU_GET_INFO( r4700le_drc ) |
| 3896 | | { |
| 3897 | | switch (state) |
| 3898 | | { |
| 3899 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3900 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3901 | | |
| 3902 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3903 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r4700le); break; |
| 3904 | | |
| 3905 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3906 | | case CPUINFO_STR_NAME: strcpy(info->s, "R4700 (little) DRC"); break; |
| 3907 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4700le_drc"); break; |
| 3908 | | |
| 3909 | | /* --- everything else is handled generically --- */ |
| 3910 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3911 | | } |
| 3912 | | } |
| 3913 | | |
| 3914 | | |
| 3915 | | |
| 3916 | | /*************************************************************************** |
| 3917 | | R5000 VARIANTS |
| 3918 | | ***************************************************************************/ |
| 3919 | | |
| 3920 | | static CPU_INIT( r5000be ) |
| 3921 | | { |
| 3922 | | mips3_init(MIPS3_TYPE_R5000, TRUE, device, irqcallback); |
| 3923 | | } |
| 3924 | | |
| 3925 | | static CPU_INIT( r5000le ) |
| 3926 | | { |
| 3927 | | mips3_init(MIPS3_TYPE_R5000, FALSE, device, irqcallback); |
| 3928 | | } |
| 3929 | | |
| 3930 | | CPU_GET_INFO( r5000be_drc ) |
| 3931 | | { |
| 3932 | | switch (state) |
| 3933 | | { |
| 3934 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3935 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3936 | | |
| 3937 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3938 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r5000be); break; |
| 3939 | | |
| 3940 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3941 | | case CPUINFO_STR_NAME: strcpy(info->s, "R5000 (big) DRC"); break; |
| 3942 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r5000be_drc"); break; |
| 3943 | | |
| 3944 | | /* --- everything else is handled generically --- */ |
| 3945 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3946 | | } |
| 3947 | | } |
| 3948 | | |
| 3949 | | CPU_GET_INFO( r5000le_drc ) |
| 3950 | | { |
| 3951 | | switch (state) |
| 3952 | | { |
| 3953 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3954 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 3955 | | |
| 3956 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3957 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(r5000le); break; |
| 3958 | | |
| 3959 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3960 | | case CPUINFO_STR_NAME: strcpy(info->s, "R5000 (little) DRC"); break; |
| 3961 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r5000le_drc"); break; |
| 3962 | | |
| 3963 | | /* --- everything else is handled generically --- */ |
| 3964 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 3965 | | } |
| 3966 | | } |
| 3967 | | |
| 3968 | | |
| 3969 | | |
| 3970 | | /*************************************************************************** |
| 3971 | | QED5271 VARIANTS |
| 3972 | | ***************************************************************************/ |
| 3973 | | |
| 3974 | | static CPU_INIT( qed5271be ) |
| 3975 | | { |
| 3976 | | mips3_init(MIPS3_TYPE_QED5271, TRUE, device, irqcallback); |
| 3977 | | } |
| 3978 | | |
| 3979 | | static CPU_INIT( qed5271le ) |
| 3980 | | { |
| 3981 | | mips3_init(MIPS3_TYPE_QED5271, FALSE, device, irqcallback); |
| 3982 | | } |
| 3983 | | |
| 3984 | | CPU_GET_INFO( qed5271be_drc ) |
| 3985 | | { |
| 3986 | | switch (state) |
| 3987 | | { |
| 3988 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 3989 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 3990 | | |
| 3991 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 3992 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(qed5271be); break; |
| 3993 | | |
| 3994 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 3995 | | case CPUINFO_STR_NAME: strcpy(info->s, "QED5271 (big) DRC"); break; |
| 3996 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "qed5271be_drc"); break; |
| 3997 | | |
| 3998 | | /* --- everything else is handled generically --- */ |
| 3999 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 4000 | | } |
| 4001 | | } |
| 4002 | | |
| 4003 | | CPU_GET_INFO( qed5271le_drc ) |
| 4004 | | { |
| 4005 | | switch (state) |
| 4006 | | { |
| 4007 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 4008 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 4009 | | |
| 4010 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 4011 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(qed5271le); break; |
| 4012 | | |
| 4013 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 4014 | | case CPUINFO_STR_NAME: strcpy(info->s, "QED5271 (little) DRC"); break; |
| 4015 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "qed5271le_drc"); break; |
| 4016 | | |
| 4017 | | /* --- everything else is handled generically --- */ |
| 4018 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 4019 | | } |
| 4020 | | } |
| 4021 | | |
| 4022 | | |
| 4023 | | |
| 4024 | | /*************************************************************************** |
| 4025 | | RM7000 VARIANTS |
| 4026 | | ***************************************************************************/ |
| 4027 | | |
| 4028 | | static CPU_INIT( rm7000be ) |
| 4029 | | { |
| 4030 | | mips3_init(MIPS3_TYPE_RM7000, TRUE, device, irqcallback); |
| 4031 | | } |
| 4032 | | |
| 4033 | | static CPU_INIT( rm7000le ) |
| 4034 | | { |
| 4035 | | mips3_init(MIPS3_TYPE_RM7000, FALSE, device, irqcallback); |
| 4036 | | } |
| 4037 | | |
| 4038 | | CPU_GET_INFO( rm7000be_drc ) |
| 4039 | | { |
| 4040 | | switch (state) |
| 4041 | | { |
| 4042 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 4043 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_BIG; break; |
| 4044 | | |
| 4045 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 4046 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(rm7000be); break; |
| 4047 | | |
| 4048 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 4049 | | case CPUINFO_STR_NAME: strcpy(info->s, "RM7000 (big) DRC"); break; |
| 4050 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "rm7000be_drc"); break; |
| 4051 | | |
| 4052 | | /* --- everything else is handled generically --- */ |
| 4053 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 4054 | | } |
| 4055 | | } |
| 4056 | | |
| 4057 | | CPU_GET_INFO( rm7000le_drc ) |
| 4058 | | { |
| 4059 | | switch (state) |
| 4060 | | { |
| 4061 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 4062 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 4063 | | |
| 4064 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 4065 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(rm7000le); break; |
| 4066 | | |
| 4067 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 4068 | | case CPUINFO_STR_NAME: strcpy(info->s, "RM7000 (little) DRC"); break; |
| 4069 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "rm7000le_drc"); break; |
| 4070 | | |
| 4071 | | /* --- everything else is handled generically --- */ |
| 4072 | | default: CPU_GET_INFO_CALL(mips3); break; |
| 4073 | | } |
| 4074 | | } |
| 4075 | | |
| 4076 | | DEFINE_LEGACY_CPU_DEVICE(VR4300BE_DRC, vr4300be_drc); |
| 4077 | | DEFINE_LEGACY_CPU_DEVICE(VR4300LE_DRC, vr4300le_drc); |
| 4078 | | DEFINE_LEGACY_CPU_DEVICE(VR4310BE_DRC, vr4310be_drc); |
| 4079 | | DEFINE_LEGACY_CPU_DEVICE(VR4310LE_DRC, vr4310le_drc); |
| 4080 | | |
| 4081 | | DEFINE_LEGACY_CPU_DEVICE(R4600BE_DRC, r4600be_drc); |
| 4082 | | DEFINE_LEGACY_CPU_DEVICE(R4600LE_DRC, r4600le_drc); |
| 4083 | | |
| 4084 | | DEFINE_LEGACY_CPU_DEVICE(R4650BE_DRC, r4650be_drc); |
| 4085 | | DEFINE_LEGACY_CPU_DEVICE(R4650LE_DRC, r4650le_drc); |
| 4086 | | |
| 4087 | | DEFINE_LEGACY_CPU_DEVICE(R4700BE_DRC, r4700be_drc); |
| 4088 | | DEFINE_LEGACY_CPU_DEVICE(R4700LE_DRC, r4700le_drc); |
| 4089 | | |
| 4090 | | DEFINE_LEGACY_CPU_DEVICE(R5000BE_DRC, r5000be_drc); |
| 4091 | | DEFINE_LEGACY_CPU_DEVICE(R5000LE_DRC, r5000le_drc); |
| 4092 | | |
| 4093 | | DEFINE_LEGACY_CPU_DEVICE(QED5271BE_DRC, qed5271be_drc); |
| 4094 | | DEFINE_LEGACY_CPU_DEVICE(QED5271LE_DRC, qed5271le_drc); |
| 4095 | | |
| 4096 | | DEFINE_LEGACY_CPU_DEVICE(RM7000BE_DRC, rm7000be_drc); |
| 4097 | | DEFINE_LEGACY_CPU_DEVICE(RM7000LE_DRC, rm7000le_drc); |