summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/mconfig.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-16 15:02:15 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-16 15:02:15 +0000
commit98c40f06dbdd764d8c1ee1409f1103ec6ec68f45 (patch)
treefb17b450cbe8daff0fed0713af377dbcbf57be84 /src/emu/mconfig.c
parent76e6a7abc46429e548db632d8f7c8eddcf58ac57 (diff)
Made CPUs into proper devices. CPUs are now added in the
machine configuration just as any other device, and the standard CPU configuration is performed via the inline configuration macros. Change cpu_type from an enumeration into a pointer to the CPU's get_info function, very similar to device behavior. For now all CPUs are declared in cpuintrf.h, but eventually they should be declared in the CPU's header file, and the driver should #include that header. Added function cpu_get_type() to return the CPU type. Changed several cpu_* functions into macros that call through to the equivalent device_* function. The device system now maintains a parallel list of devices based on type, for faster iteration through all devices of a given type. Cleaned up code that looped over CPUs via the machine->cpu array to now loop using the type-based device list. Removed start/stop/reset/nvram functions from the device_config in favor of grabbing them as needed. Cleaned up the generic interrupt_enable code to work with CPU devices instead of numbers. Mapped the devtag_* functions to device_* functions via macros instead of parallel implementations.
Diffstat (limited to 'src/emu/mconfig.c')
-rw-r--r--src/emu/mconfig.c159
1 files changed, 1 insertions, 158 deletions
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index 91898784517..92b38a9f515 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -58,16 +58,13 @@ machine_config *machine_config_alloc(const machine_config_token *tokens)
void machine_config_free(machine_config *config)
{
- int cpunum, soundnum;
+ int soundnum;
/* release the device list */
while (config->devicelist != NULL)
device_list_remove(&config->devicelist, config->devicelist->type, config->devicelist->tag);
/* release the strings */
- for (cpunum = 0; cpunum < ARRAY_LENGTH(config->cputag); cpunum++)
- if (config->cputag[cpunum] != NULL)
- astring_free(config->cputag[cpunum]);
for (soundnum = 0; soundnum < ARRAY_LENGTH(config->soundtag); soundnum++)
if (config->soundtag[soundnum] != NULL)
astring_free(config->soundtag[soundnum]);
@@ -78,75 +75,6 @@ void machine_config_free(machine_config *config)
/*-------------------------------------------------
- cpu_add - add a CPU during machine driver
- expansion
--------------------------------------------------*/
-
-static cpu_config *cpu_add(machine_config *machine, const char *tag, cpu_type type, int cpuclock)
-{
- int cpunum;
-
- for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
- if (machine->cpu[cpunum].type == CPU_DUMMY)
- {
- if (machine->cputag[cpunum] == NULL)
- machine->cputag[cpunum] = astring_alloc();
- astring_cpyc(machine->cputag[cpunum], tag);
- machine->cpu[cpunum].tag = astring_c(machine->cputag[cpunum]);
- machine->cpu[cpunum].type = type;
- machine->cpu[cpunum].clock = cpuclock;
- return &machine->cpu[cpunum];
- }
-
- fatalerror("Out of CPU's!\n");
- return NULL;
-}
-
-
-/*-------------------------------------------------
- cpu_find - find a tagged CPU during machine
- driver expansion
--------------------------------------------------*/
-
-static cpu_config *cpu_find(machine_config *machine, const char *tag)
-{
- int cpunum;
-
- for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
- if (machine->cpu[cpunum].tag && strcmp(machine->cpu[cpunum].tag, tag) == 0)
- return &machine->cpu[cpunum];
-
- fatalerror("Can't find CPU '%s'!\n", tag);
- return NULL;
-}
-
-
-/*-------------------------------------------------
- cpu_remove - remove a tagged CPU during
- machine driver expansion
--------------------------------------------------*/
-
-static void cpu_remove(machine_config *machine, const char *tag)
-{
- int cpunum;
-
- for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
- if (machine->cpu[cpunum].tag && strcmp(machine->cpu[cpunum].tag, tag) == 0)
- {
- if (machine->cputag[cpunum] != NULL)
- astring_free(machine->cputag[cpunum]);
- memmove(&machine->cpu[cpunum], &machine->cpu[cpunum + 1], sizeof(machine->cpu[0]) * (MAX_CPU - cpunum - 1));
- memmove(&machine->cputag[cpunum], &machine->cputag[cpunum + 1], sizeof(machine->cputag[0]) * (MAX_CPU - cpunum - 1));
- memset(&machine->cpu[MAX_CPU - 1], 0, sizeof(machine->cpu[0]));
- memset(&machine->cputag[MAX_CPU - 1], 0, sizeof(machine->cputag[0]));
- return;
- }
-
- fatalerror("Can't find CPU '%s'!\n", tag);
-}
-
-
-/*-------------------------------------------------
sound_add - add a sound system during
machine driver expansion
-------------------------------------------------*/
@@ -228,7 +156,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
astring *tempstring = astring_alloc();
device_config *device = NULL;
sound_config *sound = NULL;
- cpu_config *cpu = NULL;
/* loop over tokens until we hit the end */
while (entrytype != MCONFIG_TOKEN_END)
@@ -331,90 +258,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
break;
- /* add/modify/remove/replace CPUs */
- case MCONFIG_TOKEN_CPU_ADD:
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32);
- tag = TOKEN_GET_STRING(tokens);
- cpu = cpu_add(config, device_build_tag(tempstring, tagprefix, tag), type, clock);
- break;
-
- case MCONFIG_TOKEN_CPU_MODIFY:
- tag = TOKEN_GET_STRING(tokens);
- cpu = cpu_find(config, device_build_tag(tempstring, tagprefix, tag));
- break;
-
- case MCONFIG_TOKEN_CPU_REMOVE:
- tag = TOKEN_GET_STRING(tokens);
- cpu_remove(config, device_build_tag(tempstring, tagprefix, tag));
- cpu = NULL;
- break;
-
- case MCONFIG_TOKEN_CPU_REPLACE:
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32);
- tag = TOKEN_GET_STRING(tokens);
- cpu = cpu_find(config, device_build_tag(tempstring, tagprefix, tag));
- if (cpu == NULL)
- fatalerror("Unable to find CPU: tag=%s\n", astring_c(tempstring));
- cpu->type = type;
- cpu->clock = clock;
- break;
-
- /* CPU parameters */
- case MCONFIG_TOKEN_cpu_get_flags:
- assert(cpu != NULL);
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, cpu->flags, 24);
- break;
-
- case MCONFIG_TOKEN_CPU_CONFIG:
- assert(cpu != NULL);
- cpu->reset_param = TOKEN_GET_PTR(tokens, voidptr);
- break;
-
- case MCONFIG_TOKEN_CPU_PROGRAM_MAP:
- assert(cpu != NULL);
- cpu->address_map[ADDRESS_SPACE_PROGRAM][0] = TOKEN_GET_PTR(tokens, addrmap);
- cpu->address_map[ADDRESS_SPACE_PROGRAM][1] = TOKEN_GET_PTR(tokens, addrmap);
- break;
-
- case MCONFIG_TOKEN_CPU_DATA_MAP:
- assert(cpu != NULL);
- cpu->address_map[ADDRESS_SPACE_DATA][0] = TOKEN_GET_PTR(tokens, addrmap);
- cpu->address_map[ADDRESS_SPACE_DATA][1] = TOKEN_GET_PTR(tokens, addrmap);
- break;
-
- case MCONFIG_TOKEN_CPU_IO_MAP:
- assert(cpu != NULL);
- cpu->address_map[ADDRESS_SPACE_IO][0] = TOKEN_GET_PTR(tokens, addrmap);
- cpu->address_map[ADDRESS_SPACE_IO][1] = TOKEN_GET_PTR(tokens, addrmap);
- break;
-
- case MCONFIG_TOKEN_CPU_VBLANK_INT:
- assert(cpu != NULL);
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8);
- cpu->vblank_interrupt_screen = TOKEN_GET_STRING(tokens);
- cpu->vblank_interrupt = TOKEN_GET_PTR(tokens, interrupt);
- cpu->vblank_interrupts_per_frame = 1;
- break;
-
- case MCONFIG_TOKEN_CPU_VBLANK_INT_HACK:
- assert(cpu != NULL);
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, cpu->vblank_interrupts_per_frame, 24);
- cpu->vblank_interrupt = TOKEN_GET_PTR(tokens, interrupt);
- break;
-
- case MCONFIG_TOKEN_CPU_PERIODIC_INT:
- assert(cpu != NULL);
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 24);
- cpu->timed_interrupt_period = HZ_TO_ATTOSECONDS(data32);
- cpu->timed_interrupt = TOKEN_GET_PTR(tokens, interrupt);
- break;
-
/* core parameters */
case MCONFIG_TOKEN_DRIVER_DATA:
TOKEN_UNGET_UINT32(tokens);