Allow any device memory (not just CPU's) to be accessed via debug expressions.

Change eeprom accessors to require the eeprom device name.
This commit is contained in:
Aaron Giles 2009-12-27 23:10:25 +00:00
parent 0e058f3762
commit 96f9302a8c

View File

@ -25,7 +25,7 @@
#include "debugvw.h"
#include "debugger.h"
#include "uiinput.h"
#include "machine/eeprom.h"
#include "machine/eepromdev.h"
#include <ctype.h>
@ -101,11 +101,11 @@ static UINT32 dasm_wrapped(const device_config *device, char *buffer, offs_t pc)
static UINT64 expression_read_memory(void *param, const char *name, int space, UINT32 address, int size);
static UINT64 expression_read_program_direct(const address_space *space, int opcode, offs_t address, int size);
static UINT64 expression_read_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size);
static UINT64 expression_read_eeprom(running_machine *machine, offs_t address, int size);
static UINT64 expression_read_eeprom(const device_config *device, offs_t address, int size);
static void expression_write_memory(void *param, const char *name, int space, UINT32 address, int size, UINT64 data);
static void expression_write_program_direct(const address_space *space, int opcode, offs_t address, int size, UINT64 data);
static void expression_write_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size, UINT64 data);
static void expression_write_eeprom(running_machine *machine, offs_t address, int size, UINT64 data);
static void expression_write_eeprom(const device_config *device, offs_t address, int size, UINT64 data);
static EXPRERR expression_validate(void *param, const char *name, int space);
/* variable getters/setters */
@ -2437,17 +2437,17 @@ static UINT32 dasm_wrapped(const device_config *device, char *buffer, offs_t pc)
***************************************************************************/
/*-------------------------------------------------
expression_cpu_index - return the CPU index
expression_get_device - return a device
based on a case insensitive tag search
-------------------------------------------------*/
static const device_config *expression_cpu_index(running_machine *machine, const char *tag)
static const device_config *expression_get_device(running_machine *machine, const char *tag)
{
const device_config *cpu;
const device_config *device;
for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu))
if (mame_stricmp(cpu->tag, tag) == 0)
return cpu;
for (device = machine->config->devicelist.head; device != NULL; device = device->next)
if (mame_stricmp(device->tag, tag) == 0)
return device;
return NULL;
}
@ -2463,7 +2463,7 @@ static UINT64 expression_read_memory(void *param, const char *name, int spacenum
{
running_machine *machine = (running_machine *)param;
UINT64 result = ~(UINT64)0 >> (64 - 8*size);
const device_config *cpu = NULL;
const device_config *device = NULL;
const address_space *space;
switch (spacenum)
@ -2473,10 +2473,10 @@ static UINT64 expression_read_memory(void *param, const char *name, int spacenum
case EXPSPACE_IO_LOGICAL:
case EXPSPACE_SPACE3_LOGICAL:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
if (space != NULL)
result = debug_read_memory(space, memory_address_to_byte(space, address), size, TRUE);
break;
@ -2486,10 +2486,10 @@ static UINT64 expression_read_memory(void *param, const char *name, int spacenum
case EXPSPACE_IO_PHYSICAL:
case EXPSPACE_SPACE3_PHYSICAL:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
if (space != NULL)
result = debug_read_memory(space, memory_address_to_byte(space, address), size, FALSE);
break;
@ -2497,14 +2497,17 @@ static UINT64 expression_read_memory(void *param, const char *name, int spacenum
case EXPSPACE_OPCODE:
case EXPSPACE_RAMWRITE:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
result = expression_read_program_direct(cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size);
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
result = expression_read_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size);
break;
case EXPSPACE_EEPROM:
result = expression_read_eeprom(machine, address, size);
if (name != NULL)
device = expression_get_device(machine, name);
if (device != NULL)
result = expression_read_eeprom(device, address, size);
break;
case EXPSPACE_REGION:
@ -2632,14 +2635,14 @@ static UINT64 expression_read_memory_region(running_machine *machine, const char
expression_read_eeprom - read EEPROM data
-------------------------------------------------*/
static UINT64 expression_read_eeprom(running_machine *machine, offs_t address, int size)
static UINT64 expression_read_eeprom(const device_config *device, offs_t address, int size)
{
UINT64 result = ~(UINT64)0 >> (64 - 8*size);
UINT32 eelength, eesize;
void *base;
/* make sure we get a valid base before proceeding */
base = eeprom_get_data_pointer(&eelength, &eesize);
base = eepromdev_get_data_pointer(device, &eelength, &eesize);
if (base != NULL && address < eelength)
{
/* switch off the size */
@ -2662,7 +2665,7 @@ static UINT64 expression_read_eeprom(running_machine *machine, offs_t address, i
static void expression_write_memory(void *param, const char *name, int spacenum, UINT32 address, int size, UINT64 data)
{
running_machine *machine = (running_machine *)param;
const device_config *cpu = NULL;
const device_config *device = NULL;
const address_space *space;
switch (spacenum)
@ -2672,10 +2675,10 @@ static void expression_write_memory(void *param, const char *name, int spacenum,
case EXPSPACE_IO_LOGICAL:
case EXPSPACE_SPACE3_LOGICAL:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
if (space != NULL)
debug_write_memory(space, memory_address_to_byte(space, address), data, size, TRUE);
break;
@ -2685,10 +2688,10 @@ static void expression_write_memory(void *param, const char *name, int spacenum,
case EXPSPACE_IO_PHYSICAL:
case EXPSPACE_SPACE3_PHYSICAL:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
if (space != NULL)
debug_write_memory(space, memory_address_to_byte(space, address), data, size, FALSE);
break;
@ -2696,14 +2699,17 @@ static void expression_write_memory(void *param, const char *name, int spacenum,
case EXPSPACE_OPCODE:
case EXPSPACE_RAMWRITE:
if (name != NULL)
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
expression_write_program_direct(cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data);
device = expression_get_device(machine, name);
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
expression_write_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data);
break;
case EXPSPACE_EEPROM:
expression_write_eeprom(machine, address, size, data);
if (name != NULL)
device = expression_get_device(machine, name);
if (device != NULL)
expression_write_eeprom(device, address, size, data);
break;
case EXPSPACE_REGION:
@ -2843,11 +2849,11 @@ static void expression_write_memory_region(running_machine *machine, const char
expression_write_eeprom - write EEPROM data
-------------------------------------------------*/
static void expression_write_eeprom(running_machine *machine, offs_t address, int size, UINT64 data)
static void expression_write_eeprom(const device_config *device, offs_t address, int size, UINT64 data)
{
debugcpu_private *global = machine->debugcpu_data;
debugcpu_private *global = device->machine->debugcpu_data;
UINT32 eelength, eesize;
void *vbase = eeprom_get_data_pointer(&eelength, &eesize);
void *vbase = eepromdev_get_data_pointer(device, &eelength, &eesize);
/* make sure we get a valid base before proceeding */
if (vbase != NULL && address < eelength)
@ -2887,7 +2893,7 @@ static void expression_write_eeprom(running_machine *machine, offs_t address, in
static EXPRERR expression_validate(void *param, const char *name, int space)
{
running_machine *machine = (running_machine *)param;
const device_config *cpu = NULL;
const device_config *device = NULL;
switch (space)
{
@ -2897,13 +2903,13 @@ static EXPRERR expression_validate(void *param, const char *name, int space)
case EXPSPACE_SPACE3_LOGICAL:
if (name != NULL)
{
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
device = expression_get_device(machine, name);
if (device == NULL)
return EXPRERR_INVALID_MEMORY_NAME;
}
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL)) == NULL)
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL)) == NULL)
return EXPRERR_NO_SUCH_MEMORY_SPACE;
break;
@ -2913,13 +2919,13 @@ static EXPRERR expression_validate(void *param, const char *name, int space)
case EXPSPACE_SPACE3_PHYSICAL:
if (name != NULL)
{
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
device = expression_get_device(machine, name);
if (device == NULL)
return EXPRERR_INVALID_MEMORY_NAME;
}
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL)) == NULL)
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL)) == NULL)
return EXPRERR_NO_SUCH_MEMORY_SPACE;
break;
@ -2927,20 +2933,24 @@ static EXPRERR expression_validate(void *param, const char *name, int space)
case EXPSPACE_RAMWRITE:
if (name != NULL)
{
cpu = expression_cpu_index(machine, name);
if (cpu == NULL)
device = expression_get_device(machine, name);
if (device == NULL)
return EXPRERR_INVALID_MEMORY_NAME;
}
if (cpu == NULL)
cpu = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM) == NULL)
if (device == NULL)
device = debug_cpu_get_visible_cpu(machine);
if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM) == NULL)
return EXPRERR_NO_SUCH_MEMORY_SPACE;
break;
case EXPSPACE_EEPROM:
if (name != NULL)
return EXPRERR_INVALID_MEMORY_NAME;
{
device = expression_get_device(machine, name);
if (device != NULL)
break;
}
return EXPRERR_INVALID_MEMORY_NAME;
case EXPSPACE_REGION:
if (name == NULL)