From 0801d1254ca869140343236fe36f96c81d7e9ddc Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Wed, 19 Nov 2008 06:36:01 +0000 Subject: [PATCH] Converted change_pc() into a no-op. Changed memory_set_direct_region() to return a boolean indicating whether the given address was successfully located in a bank. Change raw/decrypted access to look at this result, and if the given address is not in a bank, calls through to the standard read handlers. In theory, this should prevent crashes when accessing opcodes. It does in fact prevent mp_col3 from crashing. Fixed address space mapping handlers to invalidate direct access regions if a change is made to the mapping. This is needed to prevent the Sega dynamic memory mapping chips from falling over. --- src/emu/cpu/drcfe.c | 2 +- src/emu/cpu/dsp32/dsp32.c | 4 +-- src/emu/cpu/dsp32/dsp32ops.c | 60 +++++++++++++++---------------- src/emu/cpuintrf.c | 2 +- src/emu/debug/debugcpu.c | 2 +- src/emu/debug/debugvw.c | 2 +- src/emu/memory.c | 66 +++++++++++++++++----------------- src/emu/memory.h | 70 +++++++++++++++++------------------- src/mame/machine/amiga.c | 2 +- 9 files changed, 104 insertions(+), 106 deletions(-) diff --git a/src/emu/cpu/drcfe.c b/src/emu/cpu/drcfe.c index ff68068aaed..f54c5d41505 100644 --- a/src/emu/cpu/drcfe.c +++ b/src/emu/cpu/drcfe.c @@ -301,7 +301,7 @@ static opcode_desc *describe_one(drcfe_state *drcfe, offs_t curpc, const opcode_ } /* get a pointer to the physical address */ - memory_set_direct_region(drcfe->program, desc->physpc); + change_pc(desc->physpc); desc->opptr.v = program_decrypted_read_ptr(desc->physpc ^ drcfe->codexor); assert(desc->opptr.v != NULL); if (desc->opptr.v == NULL) diff --git a/src/emu/cpu/dsp32/dsp32.c b/src/emu/cpu/dsp32/dsp32.c index 1c2ae8f3dcc..3eb7301d708 100644 --- a/src/emu/cpu/dsp32/dsp32.c +++ b/src/emu/cpu/dsp32/dsp32.c @@ -336,7 +336,7 @@ static CPU_SET_CONTEXT( dsp32c ) /* copy the context */ if (src) dsp32 = *(dsp32_regs *)src; - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); /* check for IRQs */ check_irqs(); @@ -365,7 +365,7 @@ static CPU_RESET( dsp32c ) { /* reset goes to 0 */ dsp32.PC = 0; - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); /* clear some registers */ dsp32.pcw &= 0x03ff; diff --git a/src/emu/cpu/dsp32/dsp32ops.c b/src/emu/cpu/dsp32/dsp32ops.c index 88ae50da3f0..b945e1ea4d6 100644 --- a/src/emu/cpu/dsp32/dsp32ops.c +++ b/src/emu/cpu/dsp32/dsp32ops.c @@ -692,7 +692,7 @@ static void nop(void) return; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } @@ -702,7 +702,7 @@ static void goto_t(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } @@ -713,7 +713,7 @@ static void goto_pl(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -725,7 +725,7 @@ static void goto_mi(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -737,7 +737,7 @@ static void goto_ne(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -749,7 +749,7 @@ static void goto_eq(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -761,7 +761,7 @@ static void goto_vc(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -773,7 +773,7 @@ static void goto_vs(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -785,7 +785,7 @@ static void goto_cc(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -797,7 +797,7 @@ static void goto_cs(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -809,7 +809,7 @@ static void goto_ge(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -821,7 +821,7 @@ static void goto_lt(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -833,7 +833,7 @@ static void goto_gt(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -845,7 +845,7 @@ static void goto_le(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -857,7 +857,7 @@ static void goto_hi(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -869,7 +869,7 @@ static void goto_ls(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -881,7 +881,7 @@ static void goto_auc(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -893,7 +893,7 @@ static void goto_aus(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -905,7 +905,7 @@ static void goto_age(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -917,7 +917,7 @@ static void goto_alt(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -929,7 +929,7 @@ static void goto_ane(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -941,7 +941,7 @@ static void goto_aeq(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -953,7 +953,7 @@ static void goto_avc(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -965,7 +965,7 @@ static void goto_avs(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -977,7 +977,7 @@ static void goto_agt(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -989,7 +989,7 @@ static void goto_ale(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -1100,7 +1100,7 @@ static void dec_goto(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } } @@ -1113,7 +1113,7 @@ static void call(void) dsp32.r[mr] = dsp32.PC + 4; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (INT16)op); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } @@ -1122,7 +1122,7 @@ static void goto24(void) UINT32 op = OP; execute_one(); dsp32.PC = TRUNCATE24(REG24((op >> 16) & 0x1f) + (op & 0xffff) + ((op >> 5) & 0xff0000)); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } @@ -1134,7 +1134,7 @@ static void call24(void) dsp32.r[mr] = dsp32.PC + 4; execute_one(); dsp32.PC = (op & 0xffff) + ((op >> 5) & 0xff0000); - memory_set_direct_region(dsp32.program, dsp32.PC); + change_pc(dsp32.PC); } diff --git a/src/emu/cpuintrf.c b/src/emu/cpuintrf.c index 4bb387ca064..0cc73d0bb11 100644 --- a/src/emu/cpuintrf.c +++ b/src/emu/cpuintrf.c @@ -1321,7 +1321,7 @@ void cpu_reset(const device_config *device) cpu_class_header *classheader = get_safe_classheader(device); cpu_push_context(device); - memory_set_direct_region(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 0); + change_pc(0); (*classheader->reset)(device); cpu_pop_context(); } diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index d4a9687c508..ef22ba53176 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -2086,7 +2086,7 @@ UINT64 debug_read_opcode(offs_t address, int size, int arg) address &= info->space[ADDRESS_SPACE_PROGRAM].physbytemask; /* adjust the address */ - memory_set_direct_region(cpu_get_address_space(info->device, ADDRESS_SPACE_PROGRAM), address); + change_pc(address); switch (info->space[ADDRESS_SPACE_PROGRAM].databytes * 10 + size) { diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 3fb1540445a..796a4565268 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -1596,7 +1596,7 @@ static int disasm_recompute(debug_view *view, offs_t pc, int startline, int line /* reset the opcode base */ if (dasmdata->cpunum == original_cpunum) - memory_set_direct_region(space, cpu_get_physical_pc_byte(Machine->activecpu)); + change_pc(cpu_get_physical_pc_byte(Machine->activecpu)); /* update opcode base information */ dasmdata->last_direct_decrypted = space->direct.decrypted; diff --git a/src/emu/memory.c b/src/emu/memory.c index 7f5a0158bd8..06103626a40 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -279,9 +279,11 @@ static bank_info bankdata[STATIC_COUNT]; /* data gathered for each bank */ static UINT8 * wptable; /* watchpoint-fill table */ +static void dummy_change_pc(offs_t byteaddress) { } + #define ACCESSOR_GROUP(type, width) \ { \ - type##_set_direct_region, \ + dummy_change_pc, \ type##_read_byte_##width, \ type##_read_word_##width, \ type##_read_word_masked_##width, \ @@ -1109,7 +1111,7 @@ direct_update_func memory_set_direct_update_handler(const address_space *space, update the opcode base for the given address -------------------------------------------------*/ -void memory_set_direct_region(const address_space *space, offs_t byteaddress) +int memory_set_direct_region(const address_space *space, offs_t byteaddress) { address_space *spacerw = (address_space *)space; UINT8 *base = NULL, *based = NULL; @@ -1121,7 +1123,7 @@ void memory_set_direct_region(const address_space *space, offs_t byteaddress) { byteaddress = (*spacerw->directupdate)(spacerw, byteaddress, &spacerw->direct); if (byteaddress == ~0) - return; + return TRUE; } /* perform the lookup */ @@ -1129,6 +1131,10 @@ void memory_set_direct_region(const address_space *space, offs_t byteaddress) entry = spacerw->readlookup[LEVEL1_INDEX(byteaddress)]; if (entry >= SUBTABLE_BASE) entry = spacerw->readlookup[LEVEL2_INDEX(entry,byteaddress)]; + + /* stop if nothing changed */ + if (spacerw->direct.entry == entry) + return (entry >= STATIC_BANK1 && entry < STATIC_RAM); /* keep track of current entry */ spacerw->direct.entry = entry; @@ -1148,9 +1154,8 @@ void memory_set_direct_region(const address_space *space, offs_t byteaddress) /* if nothing was found, leave everything alone */ if (entry == STATIC_COUNT) { - logerror("cpu #%d (PC=%08X): warning - op-code execute on mapped I/O\n", - cpunum_get_active(), cpu_get_pc(Machine->activecpu)); - return; + logerror("CPU '%s': warning - attempt to direct-map address %08X in %s space\n", space->cpu->tag, byteaddress, address_space_names[space->spacenum]); + return FALSE; } } @@ -1167,22 +1172,7 @@ void memory_set_direct_region(const address_space *space, offs_t byteaddress) spacerw->direct.decrypted = based - (handlers->bytestart & spacerw->direct.mask); spacerw->direct.min = handlers->bytestart; spacerw->direct.max = handlers->byteend; -} - - -void program_set_direct_region(offs_t byteaddress) -{ - memory_set_direct_region(active_address_space[ADDRESS_SPACE_PROGRAM], byteaddress); -} - -void data_set_direct_region(offs_t byteaddress) -{ - memory_set_direct_region(active_address_space[ADDRESS_SPACE_DATA], byteaddress); -} - -void io_set_direct_region(offs_t byteaddress) -{ - memory_set_direct_region(active_address_space[ADDRESS_SPACE_IO], byteaddress); + return TRUE; } @@ -1348,6 +1338,10 @@ void memory_configure_bank_decrypted(int banknum, int startentry, int numentries /* fill in the requested bank entries */ for (entrynum = startentry; entrynum < startentry + numentries; entrynum++) bankdata[banknum].entryd[entrynum] = (UINT8 *)base + (entrynum - startentry) * stride; + + /* if we have no bankptr yet, set it to the first entry */ + if (bankd_ptr[banknum] == NULL) + bankd_ptr[banknum] = bankdata[banknum].entryd[0]; } @@ -1682,8 +1676,8 @@ static void memory_init_cpudata(running_machine *machine) /* set the RAM/ROM base */ space->direct.raw = space->direct.decrypted = cpu->region; space->direct.mask = space->bytemask; - space->direct.min = 0; - space->direct.max = cpu->regionsize; + space->direct.min = 1; + space->direct.max = 0; space->direct.entry = STATIC_UNMAP; space->directupdate = NULL; } @@ -1956,6 +1950,14 @@ static void space_map_range(address_space *space, read_or_write readorwrite, int space->writelookup = space->write.table; if (reset_read) space->readlookup = space->read.table; + + /* recompute any direct access on this space if it is a read modification */ + if (readorwrite == ROW_READ && entry == space->direct.entry) + { + space->direct.entry = STATIC_UNMAP; + space->direct.min = 1; + space->direct.max = 0; + } } @@ -2803,40 +2805,40 @@ static void *memory_find_base(int cpunum, int spacenum, offs_t byteaddress) static READ8_HANDLER( unmap_read8 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory byte read from %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset)); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte read from %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset)); return space->unmap; } static READ16_HANDLER( unmap_read16 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory word read from %08X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*2), mem_mask); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory word read from %08X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*2), mem_mask); return space->unmap; } static READ32_HANDLER( unmap_read32 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory dword read from %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*4), mem_mask); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory dword read from %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*4), mem_mask); return space->unmap; } static READ64_HANDLER( unmap_read64 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory qword read from %08X & %08X%08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*8), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff)); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory qword read from %08X & %08X%08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*8), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff)); return space->unmap; } static WRITE8_HANDLER( unmap_write8 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory byte write to %08X = %02X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset), data); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte write to %08X = %02X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset), data); } static WRITE16_HANDLER( unmap_write16 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory word write to %08X = %04X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*2), data, mem_mask); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory word write to %08X = %04X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*2), data, mem_mask); } static WRITE32_HANDLER( unmap_write32 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory dword write to %08X = %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*4), data, mem_mask); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory dword write to %08X = %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*4), data, mem_mask); } static WRITE64_HANDLER( unmap_write64 ) { - if (log_unmap[space->spacenum] && !debugger_access) logerror("cpu '%s' (PC=%08X): unmapped %s memory qword write to %08X = %08X%08X & %08X%08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*8), (int)(data >> 32), (int)(data & 0xffffffff), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff)); + if (log_unmap[space->spacenum] && !debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory qword write to %08X = %08X%08X & %08X%08X\n", space->cpu->tag, cpu_get_pc(space->cpu), address_space_names[space->spacenum], cpu_byte_to_address(space->cpu, space->spacenum, offset*8), (int)(data >> 32), (int)(data & 0xffffffff), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff)); } diff --git a/src/emu/memory.h b/src/emu/memory.h index 2b31f5da11d..ebb8b02f597 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -495,7 +495,7 @@ union _addrmap64_token /* bank switching for CPU cores */ -#define change_pc(byteaddress) memory_set_direct_region(active_address_space[ADDRESS_SPACE_PROGRAM], byteaddress) +#define change_pc(byteaddress) do { /*memory_set_direct_region(active_address_space[ADDRESS_SPACE_PROGRAM], byteaddress)*/ } while (0) /* opcode range safety check */ @@ -919,7 +919,7 @@ const address_map *memory_get_address_map(int cpunum, int spacenum); -/* ----- opcode base control ----- */ +/* ----- direct access control ----- */ /* registers an address range as having a decrypted data pointer */ void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, void *base); @@ -928,7 +928,7 @@ void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, v direct_update_func memory_set_direct_update_handler(const address_space *space, direct_update_func function); /* called by CPU cores to update the opcode base for the given address */ -void memory_set_direct_region(const address_space *space, offs_t byteaddress); +int memory_set_direct_region(const address_space *space, offs_t byteaddress); @@ -1035,37 +1035,37 @@ INLINE void memory_write_qword(const address_space *space, offs_t byteaddress, U INLINE void *memory_decrypted_read_ptr(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return &space->direct.decrypted[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return &space->direct.decrypted[byteaddress & space->direct.mask]; + return NULL; } INLINE UINT8 memory_decrypted_read_byte(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return space->direct.decrypted[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return space->direct.decrypted[byteaddress & space->direct.mask]; + return memory_read_byte(space, byteaddress); } INLINE UINT16 memory_decrypted_read_word(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT16 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT16 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + return memory_read_word(space, byteaddress); } INLINE UINT32 memory_decrypted_read_dword(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT32 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT32 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + return memory_read_dword(space, byteaddress); } INLINE UINT64 memory_decrypted_read_qword(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT64 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT64 *)&space->direct.decrypted[byteaddress & space->direct.mask]; + return memory_read_qword(space, byteaddress); } @@ -1078,37 +1078,37 @@ INLINE UINT64 memory_decrypted_read_qword(const address_space *space, offs_t byt INLINE void *memory_raw_read_ptr(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return &space->direct.raw[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return &space->direct.raw[byteaddress & space->direct.mask]; + return NULL; } INLINE UINT8 memory_raw_read_byte(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return space->direct.raw[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return space->direct.raw[byteaddress & space->direct.mask]; + return memory_read_byte(space, byteaddress); } INLINE UINT16 memory_raw_read_word(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT16 *)&space->direct.raw[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT16 *)&space->direct.raw[byteaddress & space->direct.mask]; + return memory_read_word(space, byteaddress); } INLINE UINT32 memory_raw_read_dword(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT32 *)&space->direct.raw[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT32 *)&space->direct.raw[byteaddress & space->direct.mask]; + return memory_read_dword(space, byteaddress); } INLINE UINT64 memory_raw_read_qword(const address_space *space, offs_t byteaddress) { - if (address_is_unsafe(space, byteaddress)) - memory_set_direct_region(space, byteaddress); - return *(UINT64 *)&space->direct.raw[byteaddress & space->direct.mask]; + if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress)) + return *(UINT64 *)&space->direct.raw[byteaddress & space->direct.mask]; + return memory_read_qword(space, byteaddress); } @@ -1122,10 +1122,6 @@ INLINE UINT64 memory_raw_read_qword(const address_space *space, offs_t byteaddre FUNCTION PROTOTYPES FOR CORE READ/WRITE ROUTINES ***************************************************************************/ -void program_set_direct_region(offs_t byteaddress); -void data_set_direct_region(offs_t byteaddress); -void io_set_direct_region(offs_t byteaddress); - /* declare generic address space handlers */ UINT8 memory_read_byte_8le(const address_space *space, offs_t address); UINT16 memory_read_word_8le(const address_space *space, offs_t address); diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 2cd4844fbc6..aab2b677d9d 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -326,7 +326,7 @@ static void amiga_m68k_reset(const device_config *device) } if (cpu_get_pc(space->cpu) < 0x80000) - memory_set_direct_region(space, 0); + change_pc(0); }