diff --git a/src/emu/cpu/mcs48/mcs48.c b/src/emu/cpu/mcs48/mcs48.c index 99491f2bbc7..ffcb38c0e63 100644 --- a/src/emu/cpu/mcs48/mcs48.c +++ b/src/emu/cpu/mcs48/mcs48.c @@ -1299,7 +1299,7 @@ void mcs48_cpu_device::state_string_export(const device_state_entry &entry, astr { switch (entry.index()) { - case CPUINFO_STR_FLAGS: + case STATE_GENFLAGS: string.printf("%c%c %c%c%c%c%c%c%c%c", m_irq_state ? 'I':'.', m_a11 ? 'M':'.', diff --git a/src/emu/cpu/mn10200/mn10200.c b/src/emu/cpu/mn10200/mn10200.c index ba32d878630..dbde9e1c927 100644 --- a/src/emu/cpu/mn10200/mn10200.c +++ b/src/emu/cpu/mn10200/mn10200.c @@ -178,7 +178,7 @@ void mn10200_device::state_string_export(const device_state_entry &entry, astrin { switch (entry.index()) { - case CPUINFO_STR_FLAGS: + case STATE_GENFLAGS: string.printf( "S=%d irq=%s im=%d %c%c%c%c %c%c%c%c", (m_psw >> 12) & 3, m_psw & FLAG_IE ? "on " : "off", diff --git a/src/emu/devcpu.c b/src/emu/devcpu.c index 9b858636f78..797a8b49efa 100644 --- a/src/emu/devcpu.c +++ b/src/emu/devcpu.c @@ -39,419 +39,3 @@ cpu_device::~cpu_device() { } - -//------------------------------------------------- -// legacy_cpu_device - constructor -//------------------------------------------------- - -legacy_cpu_device::legacy_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, cpu_get_info_func get_info) - : cpu_device(mconfig, type, "CPU", tag, owner, clock, "", ""), - m_get_info(get_info), - m_token(NULL), - m_set_info(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_SET_INFO))), - m_execute(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_EXECUTE))), - m_burn(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_BURN))), - m_translate(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_TRANSLATE))), - m_read(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_READ))), - m_write(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_WRITE))), - m_readop(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_READOP))), - m_disassemble(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_DISASSEMBLE))), - m_state_import(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_IMPORT_STATE))), - m_state_export(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_EXPORT_STATE))), - m_string_export(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_EXPORT_STRING))), - m_exit(reinterpret_cast(get_legacy_fct(CPUINFO_FCT_EXIT))), - m_using_legacy_state(false), - m_inited(false) -{ - // build up our address spaces; legacy devices don't have logical spaces - memset(m_space_config, 0, sizeof(m_space_config)); - for (address_spacenum spacenum = AS_0; spacenum < ARRAY_LENGTH(m_space_config); spacenum++) - { - m_space_config[spacenum].m_name = (spacenum == 1) ? "data" : (spacenum == 2) ? "i/o" : "program"; - m_space_config[spacenum].m_endianness = static_cast(get_legacy_int(CPUINFO_INT_ENDIANNESS)); - m_space_config[spacenum].m_databus_width = get_legacy_int(CPUINFO_INT_DATABUS_WIDTH + spacenum); - m_space_config[spacenum].m_addrbus_width = get_legacy_int(CPUINFO_INT_ADDRBUS_WIDTH + spacenum); - m_space_config[spacenum].m_addrbus_shift = get_legacy_int(CPUINFO_INT_ADDRBUS_SHIFT + spacenum); - m_space_config[spacenum].m_logaddr_width = get_legacy_int(CPUINFO_INT_LOGADDR_WIDTH + spacenum); - if (m_space_config[spacenum].m_logaddr_width == 0) - m_space_config[spacenum].m_logaddr_width = m_space_config[spacenum].m_addrbus_width; - m_space_config[spacenum].m_page_shift = get_legacy_int(CPUINFO_INT_PAGE_SHIFT + spacenum); - m_space_config[spacenum].m_internal_map = reinterpret_cast(get_legacy_fct(CPUINFO_PTR_INTERNAL_MEMORY_MAP + spacenum)); - m_space_config[spacenum].m_default_map = reinterpret_cast(get_legacy_fct(CPUINFO_PTR_DEFAULT_MEMORY_MAP + spacenum)); - } - - // set the real name - m_name = get_legacy_string(CPUINFO_STR_NAME); - m_shortname = get_legacy_string(CPUINFO_STR_SHORTNAME); - m_source = get_legacy_string(CPUINFO_STR_SOURCE_FILE); - m_searchpath = m_shortname; - - int tokenbytes = get_legacy_int(CPUINFO_INT_CONTEXT_SIZE); - if (tokenbytes == 0) - throw emu_fatalerror("Device %s specifies a 0 context size!\n", tag); - - // allocate memory for the token - m_token = global_alloc_array_clear(UINT8, tokenbytes); - // set hex or octal output - m_is_octal = get_legacy_int(CPUINFO_IS_OCTAL); -} - - -//------------------------------------------------- -// legacy_cpu_device - destructor -//------------------------------------------------- - -legacy_cpu_device::~legacy_cpu_device() -{ - global_free_array((UINT8 *)m_token); -} - - -//------------------------------------------------- -// device_start - start up the device -//------------------------------------------------- - -void legacy_cpu_device::device_start() -{ - // standard init - cpu_init_func init = reinterpret_cast(get_legacy_fct(CPUINFO_FCT_INIT)); - (*init)(this, device_irq_acknowledge_delegate(FUNC(legacy_cpu_device::standard_irq_callback_member), this)); - m_inited = true; - - // fetch information about the CPU states - if (m_state_list.count() == 0) - { - m_using_legacy_state = true; - for (int index = 0; index < MAX_REGS; index++) - { - const char *string = get_legacy_string(CPUINFO_STR_REGISTER + index); - if (strchr(string, ':') != NULL) - { - astring tempstr(string); - bool noshow = (tempstr.chr(0, '~') == 0); - if (noshow) - tempstr.substr(1, -1); - - int colon = tempstr.chr(0, ':'); - int length = tempstr.len() - colon - 1; - - tempstr.substr(0, colon).trimspace(); - - astring formatstr; - formatstr.printf("%%%ds", length); - device_state_entry &entry = state_add(index, tempstr, m_state_io).callimport().callexport().formatstr(formatstr); - if (noshow) - entry.noshow(); - } - } - state_add(STATE_GENPC, "curpc", m_state_io).callimport().callexport().formatstr("%8s").noshow(); - state_add(STATE_GENPCBASE, "curpcbase", m_state_io).callimport().callexport().formatstr("%8s").noshow(); - - const char *string = get_legacy_string(CPUINFO_STR_FLAGS); - if (string != NULL && string[0] != 0) - { - astring flagstr; - flagstr.printf("%%%"SIZETFMT"s", strlen(string)); - state_add(STATE_GENFLAGS, "GENFLAGS", m_state_io).callimport().callexport().formatstr(flagstr).noshow(); - } - } - - // get our icount pointer - m_icountptr = reinterpret_cast(get_legacy_ptr(CPUINFO_PTR_INSTRUCTION_COUNTER)); - assert(m_icountptr != 0); - *m_icountptr = 0; -} - - -//------------------------------------------------- -// device_reset - reset up the device -//------------------------------------------------- - -void legacy_cpu_device::device_reset() -{ - cpu_reset_func reset = reinterpret_cast(get_legacy_fct(CPUINFO_FCT_RESET)); - if (reset != NULL) - (*reset)(this); -} - - -//------------------------------------------------- -// device_stop - clean up before the machine goes -// away -//------------------------------------------------- - -void legacy_cpu_device::device_stop() -{ - // call the CPU's exit function if present - if (m_inited && m_exit != NULL) - (*m_exit)(this); -} - - -//------------------------------------------------- -// execute_clocks_to_cycles - convert the raw -// clock into cycles per second -//------------------------------------------------- - -UINT64 legacy_cpu_device::execute_clocks_to_cycles(UINT64 clocks) const -{ - UINT32 multiplier = get_legacy_int(CPUINFO_INT_CLOCK_MULTIPLIER); - UINT32 divider = get_legacy_int(CPUINFO_INT_CLOCK_DIVIDER); - - if (multiplier == 0) multiplier = 1; - if (divider == 0) divider = 1; - - return (clocks * multiplier + divider - 1) / divider; -} - - -//------------------------------------------------- -// execute_cycles_to_clocks - convert a cycle -// count back to raw clocks -//------------------------------------------------- - -UINT64 legacy_cpu_device::execute_cycles_to_clocks(UINT64 cycles) const -{ - UINT32 multiplier = get_legacy_int(CPUINFO_INT_CLOCK_MULTIPLIER); - UINT32 divider = get_legacy_int(CPUINFO_INT_CLOCK_DIVIDER); - - if (multiplier == 0) multiplier = 1; - if (divider == 0) divider = 1; - - return (cycles * divider + multiplier - 1) / multiplier; -} - - -//------------------------------------------------- -// execute_run - execute for the provided number -// of cycles -//------------------------------------------------- - -void legacy_cpu_device::execute_run() -{ - (*m_execute)(this); -} - - -//------------------------------------------------- -// execute_burn - burn the requested number of cycles -//------------------------------------------------- - -void legacy_cpu_device::execute_burn(INT32 cycles) -{ - if (m_burn != NULL) - (*m_burn)(this, cycles); -} - - -//------------------------------------------------- -// memory_translate - perform address translation -// on the provided address -//------------------------------------------------- - -bool legacy_cpu_device::memory_translate(address_spacenum spacenum, int intention, offs_t &address) -{ - if (m_translate != NULL) - return (*m_translate)(this, spacenum, intention, &address) ? true : false; - return true; -} - - -//------------------------------------------------- -// memory_read - read device memory, allowing for -// device specific overrides -//------------------------------------------------- - -bool legacy_cpu_device::memory_read(address_spacenum spacenum, offs_t offset, int size, UINT64 &value) -{ - if (m_read != NULL) - return (*m_read)(this, spacenum, offset, size, &value) ? true : false; - return false; -} - - -//------------------------------------------------- -// memory_write - write device memory, allowing -// for device specific overrides -//------------------------------------------------- - -bool legacy_cpu_device::memory_write(address_spacenum spacenum, offs_t offset, int size, UINT64 value) -{ - if (m_write != NULL) - return (*m_write)(this, spacenum, offset, size, value) ? true : false; - return false; -} - - -//------------------------------------------------- -// memory_read - read device opcode memory, -// allowing for device specific overrides -//------------------------------------------------- - -bool legacy_cpu_device::memory_readop(offs_t offset, int size, UINT64 &value) -{ - if (m_readop != NULL) - return (*m_readop)(this, offset, size, &value) ? true : false; - return false; -} - - -//------------------------------------------------- -// debug_setup - set up any device-specific -// debugging commands or state -//------------------------------------------------- - -void legacy_cpu_device::device_debug_setup() -{ - cpu_debug_init_func init = reinterpret_cast(get_legacy_fct(CPUINFO_FCT_DEBUG_INIT)); - if (init != NULL) - (*init)(this); -} - - -//------------------------------------------------- -// disassemble - disassemble the provided opcode -// data to a buffer -//------------------------------------------------- - -offs_t legacy_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) -{ - // if we have a callback, just use that - if (m_disassemble != NULL) - return (*m_disassemble)(this, buffer, pc, oprom, opram, options); - - // if not, just output vanilla bytes - int width = min_opcode_bytes(); - switch (width) - { - case 1: - default: - sprintf(buffer, "$%02X", *(UINT8 *)oprom); - break; - - case 2: - sprintf(buffer, "$%04X", *(UINT16 *)oprom); - break; - - case 4: - sprintf(buffer, "$%08X", *(UINT32 *)oprom); - break; - - case 8: - sprintf(buffer, "$%08X%08X", (UINT32)(*(UINT64 *)oprom >> 32), (UINT32)(*(UINT64 *)oprom >> 0)); - break; - } - return width; -} - - -//------------------------------------------------- -// get_legacy_int - return a legacy integer value -//------------------------------------------------- - -INT64 legacy_cpu_device::get_legacy_int(UINT32 state) const -{ - cpuinfo info = { 0 }; - (*m_get_info)(const_cast(this), state, &info); - return info.i; -} - - -//------------------------------------------------- -// get_legacy_ptr - return a legacy pointer value -//------------------------------------------------- - -void *legacy_cpu_device::get_legacy_ptr(UINT32 state) const -{ - cpuinfo info = { 0 }; - (*m_get_info)(const_cast(this), state, &info); - return info.p; -} - - -//------------------------------------------------- -// get_legacy_fct - return a legacy function value -//------------------------------------------------- - -genf *legacy_cpu_device::get_legacy_fct(UINT32 state) const -{ - cpuinfo info = { 0 }; - (*m_get_info)(const_cast(this), state, &info); - return info.f; -} - - -//------------------------------------------------- -// get_legacy_string - return a legacy -// string value -//------------------------------------------------- -extern char *get_temp_string_buffer(void); - -const char *legacy_cpu_device::get_legacy_string(UINT32 state) const -{ - cpuinfo info; - info.s = get_temp_string_buffer(); - (*m_get_info)(const_cast(this), state, &info); - return info.s; -} - - -//------------------------------------------------- -// set_legacy_int - call the get info function -// to set an integer value -//------------------------------------------------- - -void legacy_cpu_device::set_legacy_int(UINT32 state, INT64 value) -{ - cpuinfo info = { 0 }; - info.i = value; - (*m_set_info)(this, state, &info); -} - - - -void legacy_cpu_device::state_import(const device_state_entry &entry) -{ - if (m_using_legacy_state) - { - if (entry.index() == STATE_GENFLAGS) - ; // do nothing - else - set_legacy_int(CPUINFO_INT_REGISTER + entry.index(), m_state_io); - } - else if (m_state_import != NULL) - (*m_state_import)(this, entry); -} - - -void legacy_cpu_device::state_export(const device_state_entry &entry) -{ - if (m_using_legacy_state) - { - if (entry.index() == STATE_GENFLAGS) - { - const char *temp = get_legacy_string(CPUINFO_STR_FLAGS); - m_state_io = 0; - while (*temp != 0) - m_state_io = ((m_state_io << 5) | (m_state_io >> (64-5))) ^ *temp++; - } - else - m_state_io = get_legacy_int(CPUINFO_INT_REGISTER + entry.index()); - } - else if (m_state_export != NULL) - (*m_state_export)(this, entry); -} - - -void legacy_cpu_device::state_string_export(const device_state_entry &entry, astring &string) -{ - if (m_using_legacy_state) - { - if (entry.index() == STATE_GENFLAGS) - string.cpy(get_legacy_string(CPUINFO_STR_FLAGS)); - else - string.cpy(strchr(get_legacy_string(CPUINFO_STR_REGISTER + entry.index()), ':') + 1); - } - else if (m_string_export != NULL) - (*m_string_export)(this, entry, string); -} diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index 95dd7bcd79d..eff1a8e8d6f 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -29,76 +29,11 @@ enum { // --- the following bits of info are returned as 64-bit signed integers --- CPUINFO_INT_FIRST = 0x00000, - CPUINFO_INT_ENDIANNESS = CPUINFO_INT_FIRST, // R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE - CPUINFO_INT_DATABUS_WIDTH, // R/O: data bus size for each address space (8,16,32,64) - CPUINFO_INT_DATABUS_WIDTH_0 = CPUINFO_INT_DATABUS_WIDTH + 0, - CPUINFO_INT_DATABUS_WIDTH_1 = CPUINFO_INT_DATABUS_WIDTH + 1, - CPUINFO_INT_DATABUS_WIDTH_2 = CPUINFO_INT_DATABUS_WIDTH + 2, - CPUINFO_INT_DATABUS_WIDTH_3 = CPUINFO_INT_DATABUS_WIDTH + 3, - CPUINFO_INT_DATABUS_WIDTH_LAST = CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACES - 1, - CPUINFO_INT_ADDRBUS_WIDTH, // R/O: address bus size for each address space (12-32) - CPUINFO_INT_ADDRBUS_WIDTH_0 = CPUINFO_INT_ADDRBUS_WIDTH + 0, - CPUINFO_INT_ADDRBUS_WIDTH_1 = CPUINFO_INT_ADDRBUS_WIDTH + 1, - CPUINFO_INT_ADDRBUS_WIDTH_2 = CPUINFO_INT_ADDRBUS_WIDTH + 2, - CPUINFO_INT_ADDRBUS_WIDTH_3 = CPUINFO_INT_ADDRBUS_WIDTH + 3, - CPUINFO_INT_ADDRBUS_WIDTH_LAST = CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACES - 1, - CPUINFO_INT_ADDRBUS_SHIFT, // R/O: shift applied to addresses each address space (+3 means >>3, -1 means <<1) - CPUINFO_INT_ADDRBUS_SHIFT_0 = CPUINFO_INT_ADDRBUS_SHIFT + 0, - CPUINFO_INT_ADDRBUS_SHIFT_1 = CPUINFO_INT_ADDRBUS_SHIFT + 1, - CPUINFO_INT_ADDRBUS_SHIFT_2 = CPUINFO_INT_ADDRBUS_SHIFT + 2, - CPUINFO_INT_ADDRBUS_SHIFT_3 = CPUINFO_INT_ADDRBUS_SHIFT + 3, - CPUINFO_INT_ADDRBUS_SHIFT_LAST = CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACES - 1, - - // CPU-specific additionsg - CPUINFO_INT_CONTEXT_SIZE = 0x04000, // R/O: size of CPU context in bytes - CPUINFO_INT_INPUT_LINES, // R/O: number of input lines - CPUINFO_INT_DEFAULT_IRQ_VECTOR, // R/O: default IRQ vector - CPUINFO_INT_CLOCK_MULTIPLIER, // R/O: internal clock multiplier - CPUINFO_INT_CLOCK_DIVIDER, // R/O: internal clock divider - CPUINFO_INT_MIN_INSTRUCTION_BYTES, // R/O: minimum bytes per instruction - CPUINFO_INT_MAX_INSTRUCTION_BYTES, // R/O: maximum bytes per instruction - CPUINFO_INT_MIN_CYCLES, // R/O: minimum cycles for a single instruction - CPUINFO_INT_MAX_CYCLES, // R/O: maximum cycles for a single instruction - - CPUINFO_INT_LOGADDR_WIDTH, // R/O: address bus size for logical accesses in each space (0=same as physical) - CPUINFO_INT_LOGADDR_WIDTH_PROGRAM = CPUINFO_INT_LOGADDR_WIDTH + AS_PROGRAM, - CPUINFO_INT_LOGADDR_WIDTH_DATA = CPUINFO_INT_LOGADDR_WIDTH + AS_DATA, - CPUINFO_INT_LOGADDR_WIDTH_IO = CPUINFO_INT_LOGADDR_WIDTH + AS_IO, - CPUINFO_INT_LOGADDR_WIDTH_LAST = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACES - 1, - CPUINFO_INT_PAGE_SHIFT, // R/O: size of a page log 2 (i.e., 12=4096), or 0 if paging not supported - CPUINFO_INT_PAGE_SHIFT_PROGRAM = CPUINFO_INT_PAGE_SHIFT + AS_PROGRAM, - CPUINFO_INT_PAGE_SHIFT_DATA = CPUINFO_INT_PAGE_SHIFT + AS_DATA, - CPUINFO_INT_PAGE_SHIFT_IO = CPUINFO_INT_PAGE_SHIFT + AS_IO, - CPUINFO_INT_PAGE_SHIFT_LAST = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACES - 1, - - CPUINFO_INT_INPUT_STATE, // R/W: states for each input line - CPUINFO_INT_INPUT_STATE_LAST = CPUINFO_INT_INPUT_STATE + MAX_INPUT_LINES - 1, - CPUINFO_INT_REGISTER = CPUINFO_INT_INPUT_STATE_LAST + 10, // R/W: values of up to MAX_REGs registers - CPUINFO_INT_SP = CPUINFO_INT_REGISTER + STATE_GENSP, // R/W: the current stack pointer value - CPUINFO_INT_PC = CPUINFO_INT_REGISTER + STATE_GENPC, // R/W: the current PC value - CPUINFO_INT_PREVIOUSPC = CPUINFO_INT_REGISTER + STATE_GENPCBASE, // R/W: the previous PC value - - CPUINFO_IS_OCTAL = CPUINFO_INT_REGISTER + MAX_REGS - 2, // R/O: determine if default is octal or hexadecimal - - CPUINFO_INT_REGISTER_LAST = CPUINFO_INT_REGISTER + MAX_REGS - 1, CPUINFO_INT_CPU_SPECIFIC = 0x08000, // R/W: CPU-specific values start here // --- the following bits of info are returned as pointers to data or functions --- CPUINFO_PTR_FIRST = 0x10000, - CPUINFO_PTR_INTERNAL_MEMORY_MAP = CPUINFO_PTR_FIRST, // R/O: address_map_constructor map - CPUINFO_PTR_INTERNAL_MEMORY_MAP_0 = CPUINFO_PTR_INTERNAL_MEMORY_MAP + 0, - CPUINFO_PTR_INTERNAL_MEMORY_MAP_1 = CPUINFO_PTR_INTERNAL_MEMORY_MAP + 1, - CPUINFO_PTR_INTERNAL_MEMORY_MAP_2 = CPUINFO_PTR_INTERNAL_MEMORY_MAP + 2, - CPUINFO_PTR_INTERNAL_MEMORY_MAP_3 = CPUINFO_PTR_INTERNAL_MEMORY_MAP + 3, - CPUINFO_PTR_INTERNAL_MEMORY_MAP_LAST = CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1, - - CPUINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: address_map_constructor map - CPUINFO_PTR_DEFAULT_MEMORY_MAP_0 = CPUINFO_PTR_DEFAULT_MEMORY_MAP + 0, - CPUINFO_PTR_DEFAULT_MEMORY_MAP_1 = CPUINFO_PTR_DEFAULT_MEMORY_MAP + 1, - CPUINFO_PTR_DEFAULT_MEMORY_MAP_2 = CPUINFO_PTR_DEFAULT_MEMORY_MAP + 2, - CPUINFO_PTR_DEFAULT_MEMORY_MAP_3 = CPUINFO_PTR_DEFAULT_MEMORY_MAP + 3, - CPUINFO_PTR_DEFAULT_MEMORY_MAP_LAST = CPUINFO_PTR_DEFAULT_MEMORY_MAP + ADDRESS_SPACES - 1, // CPU-specific additions CPUINFO_PTR_INSTRUCTION_COUNTER = 0x14000, @@ -109,38 +44,10 @@ enum // --- the following bits of info are returned as pointers to functions --- CPUINFO_FCT_FIRST = 0x20000, - // CPU-specific additions - CPUINFO_FCT_SET_INFO = 0x24000, // R/O: void (*set_info)(legacy_cpu_device *device, UINT32 state, INT64 data, void *ptr) - CPUINFO_FCT_INIT, // R/O: void (*init)(legacy_cpu_device *device, int index, int clock, int (*irqcallback)(legacy_cpu_device *device, int)) - CPUINFO_FCT_RESET, // R/O: void (*reset)(legacy_cpu_device *device) - CPUINFO_FCT_EXIT, // R/O: void (*exit)(legacy_cpu_device *device) - CPUINFO_FCT_EXECUTE, // R/O: int (*execute)(legacy_cpu_device *device, int cycles) - CPUINFO_FCT_BURN, // R/O: void (*burn)(legacy_cpu_device *device, int cycles) - CPUINFO_FCT_DISASSEMBLE, // R/O: offs_t (*disassemble)(cpu_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) - CPUINFO_FCT_TRANSLATE, // R/O: int (*translate)(legacy_cpu_device *device, address_spacenum space, int intention, offs_t *address) - CPUINFO_FCT_READ, // R/O: int (*read)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 *value) - CPUINFO_FCT_WRITE, // R/O: int (*write)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 value) - CPUINFO_FCT_READOP, // R/O: int (*readop)(legacy_cpu_device *device, UINT32 offset, int size, UINT64 *value) - CPUINFO_FCT_DEBUG_INIT, // R/O: void (*debug_init)(legacy_cpu_device *device) - CPUINFO_FCT_IMPORT_STATE, // R/O: void (*import_state)(legacy_cpu_device *device, const device_state_entry &entry) - CPUINFO_FCT_EXPORT_STATE, // R/O: void (*export_state)(legacy_cpu_device *device, const device_state_entry &entry) - CPUINFO_FCT_IMPORT_STRING, // R/O: void (*import_string)(legacy_cpu_device *device, const device_state_entry &entry, astring &string) - CPUINFO_FCT_EXPORT_STRING, // R/O: void (*export_string)(legacy_cpu_device *device, const device_state_entry &entry, astring &string) - CPUINFO_FCT_CPU_SPECIFIC = 0x28000, // R/W: CPU-specific values start here // --- the following bits of info are returned as NULL-terminated strings --- CPUINFO_STR_FIRST = 0x30000, - CPUINFO_STR_NAME = CPUINFO_STR_FIRST, // R/O: name of the device - CPUINFO_STR_SHORTNAME, // R/O: search path of device, used for media loading - CPUINFO_STR_FAMILY, // R/O: family of the device - CPUINFO_STR_VERSION, // R/O: version of the device - CPUINFO_STR_SOURCE_FILE, // R/O: file containing the device implementation - CPUINFO_STR_CREDITS, // R/O: credits for the device implementation - // CPU-specific additions - CPUINFO_STR_REGISTER = 0x34000 + 10, // R/O: string representation of up to MAX_REGs registers - CPUINFO_STR_FLAGS = CPUINFO_STR_REGISTER + STATE_GENFLAGS, // R/O: string representation of the main flags value - CPUINFO_STR_REGISTER_LAST = CPUINFO_STR_REGISTER + MAX_REGS - 1, CPUINFO_STR_CPU_SPECIFIC = 0x38000 // R/W: CPU-specific values start here }; @@ -176,166 +83,15 @@ enum // MACROS //************************************************************************** -// macro for defining the implementation needed for configuration and device classes -#define DEFINE_LEGACY_CPU_DEVICE(name, basename) \ - \ -basename##_device::basename##_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock) \ - : legacy_cpu_device(mconfig, type, tag, owner, clock, CPU_GET_INFO_NAME(basename)) \ -{ \ -} \ - \ -const device_type name = &legacy_device_creator - - - -// CPU interface functions -#define CPU_GET_INFO_NAME(name) cpu_get_info_##name -#define CPU_GET_INFO(name) void CPU_GET_INFO_NAME(name)(legacy_cpu_device *device, UINT32 state, cpuinfo *info) -#define CPU_GET_INFO_CALL(name) CPU_GET_INFO_NAME(name)(device, state, info) - -#define CPU_SET_INFO_NAME(name) cpu_set_info_##name -#define CPU_SET_INFO(name) void CPU_SET_INFO_NAME(name)(legacy_cpu_device *device, UINT32 state, cpuinfo *info) -#define CPU_SET_INFO_CALL(name) CPU_SET_INFO_NAME(name)(device, state, info) - -#define CPU_INIT_NAME(name) cpu_init_##name -#define CPU_INIT(name) void CPU_INIT_NAME(name)(legacy_cpu_device *device, device_irq_acknowledge_delegate irqcallback) -#define CPU_INIT_CALL(name) CPU_INIT_NAME(name)(device, irqcallback) - -#define CPU_RESET_NAME(name) cpu_reset_##name -#define CPU_RESET(name) void CPU_RESET_NAME(name)(legacy_cpu_device *device) -#define CPU_RESET_CALL(name) CPU_RESET_NAME(name)(device) - -#define CPU_EXIT_NAME(name) cpu_exit_##name -#define CPU_EXIT(name) void CPU_EXIT_NAME(name)(legacy_cpu_device *device) -#define CPU_EXIT_CALL(name) CPU_EXIT_NAME(name)(device) - -#define CPU_EXECUTE_NAME(name) cpu_execute_##name -#define CPU_EXECUTE(name) void CPU_EXECUTE_NAME(name)(legacy_cpu_device *device) -#define CPU_EXECUTE_CALL(name) CPU_EXECUTE_NAME(name)(device, cycles) - -#define CPU_BURN_NAME(name) cpu_burn_##name -#define CPU_BURN(name) void CPU_BURN_NAME(name)(legacy_cpu_device *device, int cycles) -#define CPU_BURN_CALL(name) CPU_BURN_NAME(name)(device, cycles) - -#define CPU_TRANSLATE_NAME(name) cpu_translate_##name -#define CPU_TRANSLATE(name) int CPU_TRANSLATE_NAME(name)(legacy_cpu_device *device, address_spacenum space, int intention, offs_t *address) -#define CPU_TRANSLATE_CALL(name) CPU_TRANSLATE_NAME(name)(device, space, intention, address) - -#define CPU_READ_NAME(name) cpu_read_##name -#define CPU_READ(name) int CPU_READ_NAME(name)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 *value) -#define CPU_READ_CALL(name) CPU_READ_NAME(name)(device, space, offset, size, value) - -#define CPU_WRITE_NAME(name) cpu_write_##name -#define CPU_WRITE(name) int CPU_WRITE_NAME(name)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 value) -#define CPU_WRITE_CALL(name) CPU_WRITE_NAME(name)(device, space, offset, size, value) - -#define CPU_READOP_NAME(name) cpu_readop_##name -#define CPU_READOP(name) int CPU_READOP_NAME(name)(legacy_cpu_device *device, UINT32 offset, int size, UINT64 *value) -#define CPU_READOP_CALL(name) CPU_READOP_NAME(name)(device, offset, size, value) - -#define CPU_DEBUG_INIT_NAME(name) cpu_debug_init_##name -#define CPU_DEBUG_INIT(name) void CPU_DEBUG_INIT_NAME(name)(legacy_cpu_device *device) -#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)(device) - #define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name #define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(cpu_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) #define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram, options) -#define CPU_IMPORT_STATE_NAME(name) cpu_state_import_##name -#define CPU_IMPORT_STATE(name) void CPU_IMPORT_STATE_NAME(name)(legacy_cpu_device *device, const device_state_entry &entry) -#define CPU_IMPORT_STATE_CALL(name) CPU_IMPORT_STATE_NAME(name)(device, entry) - -#define CPU_EXPORT_STATE_NAME(name) cpu_state_export_##name -#define CPU_EXPORT_STATE(name) void CPU_EXPORT_STATE_NAME(name)(legacy_cpu_device *device, const device_state_entry &entry) -#define CPU_EXPORT_STATE_CALL(name) CPU_EXPORT_STATE_NAME(name)(device, entry) - -#define CPU_EXPORT_STRING_NAME(name) cpu_string_export_##name -#define CPU_EXPORT_STRING(name) void CPU_EXPORT_STRING_NAME(name)(legacy_cpu_device *device, const device_state_entry &entry, astring &string) -#define CPU_EXPORT_STRING_CALL(name) CPU_EXPORT_STRING_NAME(name)(device, entry, string) - - -// this template function creates a stub which constructs a device -template -device_t *legacy_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) -{ - return global_alloc(_DeviceClass(mconfig, &legacy_device_creator<_DeviceClass>, tag, owner, clock)); -} - -// this template function creates a stub which constructs a device -template -device_t *legacy_device_creator_drc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) -{ - if (mconfig.options().drc()) - return global_alloc(_DeviceClass2(mconfig, &legacy_device_creator<_DeviceClass2>, tag, owner, clock)); - else - return global_alloc(_DeviceClass1(mconfig, &legacy_device_creator<_DeviceClass1>, tag, owner, clock)); -} //************************************************************************** // TYPE DEFINITIONS //************************************************************************** -// forward declaration of types -union cpuinfo; -class cpu_device; -class legacy_cpu_device; - - -// CPU interface functions -typedef void (*cpu_get_info_func)(legacy_cpu_device *device, UINT32 state, cpuinfo *info); -typedef void (*cpu_set_info_func)(legacy_cpu_device *device, UINT32 state, cpuinfo *info); -typedef void (*cpu_init_func)(legacy_cpu_device *device, device_irq_acknowledge_delegate irqcallback); -typedef void (*cpu_reset_func)(legacy_cpu_device *device); -typedef void (*cpu_exit_func)(legacy_cpu_device *device); -typedef void (*cpu_execute_func)(legacy_cpu_device *device); -typedef void (*cpu_burn_func)(legacy_cpu_device *device, int cycles); -typedef int (*cpu_translate_func)(legacy_cpu_device *device, address_spacenum space, int intention, offs_t *address); -typedef int (*cpu_read_func)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 *value); -typedef int (*cpu_write_func)(legacy_cpu_device *device, address_spacenum space, UINT32 offset, int size, UINT64 value); -typedef int (*cpu_readop_func)(legacy_cpu_device *device, UINT32 offset, int size, UINT64 *value); -typedef void (*cpu_debug_init_func)(legacy_cpu_device *device); -typedef offs_t (*cpu_disassemble_func)(cpu_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); -typedef void (*cpu_state_io_func)(legacy_cpu_device *device, const device_state_entry &entry); -typedef void (*cpu_string_io_func)(legacy_cpu_device *device, const device_state_entry &entry, astring &string); - - -// cpuinfo union used to pass data to/from the get_info/set_info functions -union cpuinfo -{ - INT64 i; // generic integers - void * p; // generic pointers - genf * f; // generic function pointers - char * s; // generic strings - - cpu_set_info_func setinfo; // CPUINFO_FCT_SET_INFO - cpu_init_func init; // CPUINFO_FCT_INIT - cpu_reset_func reset; // CPUINFO_FCT_RESET - cpu_exit_func exit; // CPUINFO_FCT_EXIT - cpu_execute_func execute; // CPUINFO_FCT_EXECUTE - cpu_burn_func burn; // CPUINFO_FCT_BURN - cpu_translate_func translate; // CPUINFO_FCT_TRANSLATE - cpu_read_func read; // CPUINFO_FCT_READ - cpu_write_func write; // CPUINFO_FCT_WRITE - cpu_readop_func readop; // CPUINFO_FCT_READOP - cpu_debug_init_func debug_init; // CPUINFO_FCT_DEBUG_INIT - cpu_disassemble_func disassemble; // CPUINFO_FCT_DISASSEMBLE - cpu_state_io_func import_state; // CPUINFO_FCT_IMPORT_STATE - cpu_state_io_func export_state; // CPUINFO_FCT_EXPORT_STATE - cpu_string_io_func import_string; // CPUINFO_FCT_IMPORT_STRING - cpu_string_io_func export_string; // CPUINFO_FCT_EXPORT_STRING - int * icount; // CPUINFO_PTR_INSTRUCTION_COUNTER - address_map_constructor internal_map8; // CPUINFO_PTR_INTERNAL_MEMORY_MAP - address_map_constructor internal_map16; // CPUINFO_PTR_INTERNAL_MEMORY_MAP - address_map_constructor internal_map32; // CPUINFO_PTR_INTERNAL_MEMORY_MAP - address_map_constructor internal_map64; // CPUINFO_PTR_INTERNAL_MEMORY_MAP - address_map_constructor default_map8; // CPUINFO_PTR_DEFAULT_MEMORY_MAP - address_map_constructor default_map16; // CPUINFO_PTR_DEFAULT_MEMORY_MAP - address_map_constructor default_map32; // CPUINFO_PTR_DEFAULT_MEMORY_MAP - address_map_constructor default_map64; // CPUINFO_PTR_DEFAULT_MEMORY_MAP -}; - - - // ======================> cpu_device class cpu_device : public device_t, @@ -353,86 +109,7 @@ protected: }; - -// ======================> legacy_cpu_device - -class legacy_cpu_device : public cpu_device -{ - friend resource_pool_object::~resource_pool_object(); - -protected: - // construction/destruction - legacy_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, cpu_get_info_func info); - virtual ~legacy_cpu_device(); - -public: - void *token() const { return m_token; } - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_stop(); - virtual void device_debug_setup(); - - // device_execute_interface overrides - virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const; - virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const; - virtual UINT32 execute_min_cycles() const { return get_legacy_int(CPUINFO_INT_MIN_CYCLES); } - virtual UINT32 execute_max_cycles() const { return get_legacy_int(CPUINFO_INT_MAX_CYCLES); } - virtual UINT32 execute_input_lines() const { return get_legacy_int(CPUINFO_INT_INPUT_LINES); } - virtual UINT32 execute_default_irq_vector() const { return get_legacy_int(CPUINFO_INT_DEFAULT_IRQ_VECTOR); } - virtual void execute_run(); - virtual void execute_burn(INT32 cycles); - virtual void execute_set_input(int inputnum, int state) { set_legacy_int(CPUINFO_INT_INPUT_STATE + inputnum, state); } - - // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum < ARRAY_LENGTH(m_space_config) && m_space_config[spacenum].m_addrbus_width != 0) ? &m_space_config[spacenum] : NULL; } - virtual bool memory_translate(address_spacenum spacenum, int intention, offs_t &address); - virtual bool memory_read(address_spacenum spacenum, offs_t offset, int size, UINT64 &value); - virtual bool memory_write(address_spacenum spacenum, offs_t offset, int size, UINT64 value); - virtual bool memory_readop(offs_t offset, int size, UINT64 &value); - - // device_state_interface overrides - virtual void state_import(const device_state_entry &entry); - virtual void state_export(const device_state_entry &entry); - virtual void state_string_export(const device_state_entry &entry, astring &string); - - // device_disasm_interface overrides - virtual UINT32 disasm_min_opcode_bytes() const { return get_legacy_int(CPUINFO_INT_MIN_INSTRUCTION_BYTES); } - virtual UINT32 disasm_max_opcode_bytes() const { return get_legacy_int(CPUINFO_INT_MAX_INSTRUCTION_BYTES); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); - - // helpers to access data via the legacy get_info functions - INT64 get_legacy_int(UINT32 state) const; - void *get_legacy_ptr(UINT32 state) const; - genf *get_legacy_fct(UINT32 state) const; - const char *get_legacy_string(UINT32 state) const; - void set_legacy_int(UINT32 state, INT64 value); - -protected: - // internal state - cpu_get_info_func m_get_info; - address_space_config m_space_config[3]; // array of address space configs - void * m_token; // pointer to our state - - cpu_set_info_func m_set_info; // extracted legacy function pointers - cpu_execute_func m_execute; // - cpu_burn_func m_burn; // - cpu_translate_func m_translate; // - cpu_read_func m_read; // - cpu_write_func m_write; // - cpu_readop_func m_readop; // - cpu_disassemble_func m_disassemble; // - cpu_state_io_func m_state_import; // - cpu_state_io_func m_state_export; // - cpu_string_io_func m_string_export; // - cpu_exit_func m_exit; // - - UINT64 m_state_io; // temporary buffer for state I/O - bool m_using_legacy_state; // true if we are using the old-style state access - bool m_inited; -}; +typedef offs_t (*cpu_disassemble_func)(cpu_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); #endif /* __CPUINTRF_H__ */