summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/memory.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-03 06:35:34 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-03 06:35:34 +0000
commitd924407859fbb4d9468655858078c14e54ac74fe (patch)
tree0b34c4e1800958e8f3fdbd75048b34567530fa01 /src/emu/memory.c
parente16734f2f3dff3eed7f3bd19dc3074fce8b67cc5 (diff)
Big debugger cleanup.
Important note for OSD ports: the get/set property functions have been retired for debug_views. Instead, there are specific functions to perform each get/set operation. In addition, the format of the update callback has changed to pass the osd private data in, and the update callback/osd private data must be passed in at view allocation time. And osd_wait_for_debugger() now gets a CPU object instead of the machine. Removed extra debugger tracking for address spaces and added some of the useful data to the address_space structure. Updated all debugger commands and views to use CPU and address space objects where appropriate. Added new memory functions for converting between bytes and addresses, and for performing translations for a given address space. Removed debugger macros that did similar things in favor of calling these functions. Rewrote most of the memory view handling. Disasm and register views still need some additional tweaking.
Diffstat (limited to 'src/emu/memory.c')
-rw-r--r--src/emu/memory.c71
1 files changed, 52 insertions, 19 deletions
diff --git a/src/emu/memory.c b/src/emu/memory.c
index a7fde05120a..ef996c1bd9a 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -1317,6 +1317,27 @@ UINT64 *_memory_install_device_handler64(const address_space *space, const devic
/***************************************************************************
+ MISCELLANEOUS UTILITIES
+***************************************************************************/
+
+/*-------------------------------------------------
+ memory_address_physical - return the physical
+ address corresponding to the given logical
+ address
+-------------------------------------------------*/
+
+int memory_address_physical(const address_space *space, int intention, offs_t *address)
+{
+ cpu_class_header *classheader = space->cpu->classtoken;
+ if (classheader->translate != NULL)
+ return (*classheader->translate)(space->cpu, space->spacenum, intention, address);
+ else
+ return TRUE;
+}
+
+
+
+/***************************************************************************
DEBUGGER HELPERS
***************************************************************************/
@@ -1473,24 +1494,36 @@ static void memory_init_spaces(running_machine *machine)
if (cputype_get_addrbus_width(cputype, spacenum) > 0)
{
address_space *space = malloc_or_die(sizeof(*space));
- int accessorindex;
+ int logbits = cputype_get_logaddr_width(cputype, spacenum);
+ int ashift = cputype_get_addrbus_shift(cputype, spacenum);
+ int abits = cputype_get_addrbus_width(cputype, spacenum);
+ int dbits = cputype_get_databus_width(cputype, spacenum);
+ int endianness = cputype_get_endianness(cputype);
+ int accessorindex = (dbits == 8) ? 0 : (dbits == 16) ? 1 : (dbits == 32) ? 2 : 3;
int entrynum;
+
+ /* if logbits is 0, revert to abits */
+ if (logbits == 0)
+ logbits = abits;
/* determine the address and data bits */
memset(space, 0, sizeof(*space));
space->machine = machine;
space->cpu = machine->cpu[cpunum];
- space->spacenum = spacenum;
space->name = address_space_names[spacenum];
- space->endianness = cputype_get_endianness(cputype);
- space->ashift = cputype_get_addrbus_shift(cputype, spacenum);
- space->abits = cputype_get_addrbus_width(cputype, spacenum);
- space->dbits = cputype_get_databus_width(cputype, spacenum);
- space->addrmask = 0xffffffffUL >> (32 - space->abits);
- space->bytemask = ADDR2BYTE_END(space, space->addrmask);
- accessorindex = (space->dbits == 8) ? 0 : (space->dbits == 16) ? 1 : (space->dbits == 32) ? 2 : 3;
- space->accessors = memory_accessors[accessorindex][(space->endianness == CPU_IS_LE) ? 0 : 1];
- space->map = NULL;
+ space->accessors = memory_accessors[accessorindex][(endianness == CPU_IS_LE) ? 0 : 1];
+ space->addrmask = 0xffffffffUL >> (32 - abits);
+ space->bytemask = (ashift < 0) ? ((space->addrmask << -ashift) | ((1 << -ashift) - 1)) : (space->addrmask >> ashift);
+ space->logaddrmask = 0xffffffffUL >> (32 - logbits);
+ space->logbytemask = (ashift < 0) ? ((space->logaddrmask << -ashift) | ((1 << -ashift) - 1)) : (space->logaddrmask >> ashift);
+ space->spacenum = spacenum;
+ space->endianness = endianness;
+ space->ashift = ashift;
+ space->pageshift = cputype_get_page_shift(cputype, spacenum);
+ space->abits = abits;
+ space->dbits = dbits;
+ space->addrchars = (abits + 3) / 4;
+ space->logaddrchars = (logbits + 3) / 4;
space->log_unmap = TRUE;
/* allocate subtable information; we malloc this manually because it will be realloc'ed */
@@ -2931,40 +2964,40 @@ static address_map_entry *block_assign_intersecting(address_space *space, offs_t
static READ8_HANDLER( unmap_read8 )
{
- if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte read from %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset));
+ if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte read from %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, memory_byte_to_address(space, offset));
return space->unmap;
}
static READ16_HANDLER( unmap_read16 )
{
- if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory word read from %08X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset*2), mem_mask);
+ if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory word read from %08X & %04X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, memory_byte_to_address(space, offset*2), mem_mask);
return space->unmap;
}
static READ32_HANDLER( unmap_read32 )
{
- if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory dword read from %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset*4), mem_mask);
+ if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory dword read from %08X & %08X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, memory_byte_to_address(space, offset*4), mem_mask);
return space->unmap;
}
static READ64_HANDLER( unmap_read64 )
{
- if (space->log_unmap && !space->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), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset*8), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff));
+ if (space->log_unmap && !space->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), space->name, memory_byte_to_address(space, offset*8), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff));
return space->unmap;
}
static WRITE8_HANDLER( unmap_write8 )
{
- if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte write to %08X = %02X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset), data);
+ if (space->log_unmap && !space->debugger_access) logerror("CPU '%s' (PC=%08X): unmapped %s memory byte write to %08X = %02X\n", space->cpu->tag, cpu_get_pc(space->cpu), space->name, memory_byte_to_address(space, offset), data);
}
static WRITE16_HANDLER( unmap_write16 )
{
- if (space->log_unmap && !space->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), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset*2), data, mem_mask);
+ if (space->log_unmap && !space->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), space->name, memory_byte_to_address(space, offset*2), data, mem_mask);
}
static WRITE32_HANDLER( unmap_write32 )
{
- if (space->log_unmap && !space->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), space->name, cpu_byte_to_address(space->cpu, space->spacenum, offset*4), data, mem_mask);
+ if (space->log_unmap && !space->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), space->name, memory_byte_to_address(space, offset*4), data, mem_mask);
}
static WRITE64_HANDLER( unmap_write64 )
{
- if (space->log_unmap && !space->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), space->name, 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 (space->log_unmap && !space->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), space->name, memory_byte_to_address(space, offset*8), (int)(data >> 32), (int)(data & 0xffffffff), (int)(mem_mask >> 32), (int)(mem_mask & 0xffffffff));
}