--- trunk/src/cpus/cpu_m68k.c 2007/10/08 16:20:48 31 +++ trunk/src/cpus/cpu_m68k.c 2007/10/08 16:20:58 32 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: cpu_m68k.c,v 1.12 2006/07/20 21:52:59 debug Exp $ + * $Id: cpu_m68k.c,v 1.14 2006/09/19 10:50:08 debug Exp $ * * Motorola 68K CPU emulation. */ @@ -39,6 +39,7 @@ #include "machine.h" #include "memory.h" #include "misc.h" +#include "settings.h" #include "symbol.h" @@ -48,6 +49,7 @@ static char *m68k_aname[] = { "a0", "a1", "a2", "a3", "a4", "a5", "fp", "a7" }; +static char *m68k_dname[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7" }; /* @@ -61,7 +63,17 @@ int m68k_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, int cpu_id, char *cpu_type_name) { - if (strcasecmp(cpu_type_name, "68020") != 0) + int i = 0; + struct m68k_cpu_type_def cpu_type_defs[] = M68K_CPU_TYPE_DEFS; + + /* Scan the cpu_type_defs list for this cpu type: */ + while (cpu_type_defs[i].name != NULL) { + if (strcasecmp(cpu_type_defs[i].name, cpu_type_name) == 0) { + break; + } + i++; + } + if (cpu_type_defs[i].name == NULL) return 0; cpu->run_instr = m68k_run_instr; @@ -71,14 +83,24 @@ m68k_invalidate_translation_caches; cpu->invalidate_code_translation = m68k_invalidate_code_translation; cpu->is_32bit = 1; - cpu->byte_order = EMUL_BIG_ENDIAN; + cpu->cd.m68k.cpu_type = cpu_type_defs[i]; + /* Only show name and caches etc for CPU nr 0 (in SMP machines): */ if (cpu_id == 0) { debug("%s", cpu->name); } + /* Add all register names to the settings: */ + CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); + for (i=0; icd.m68k.a[i]); + /* Both "fp" and "a6" should map to the same register: */ + CPU_SETTINGS_ADD_REGISTER32("a6", cpu->cd.m68k.a[6]); + for (i=0; icd.m68k.d[i]); + return 1; } @@ -90,8 +112,17 @@ */ void m68k_cpu_list_available_types(void) { - debug("68020\n"); - /* TODO */ + int i = 0, j; + struct m68k_cpu_type_def tdefs[] = M68K_CPU_TYPE_DEFS; + + while (tdefs[i].name != NULL) { + debug("%s", tdefs[i].name); + for (j=10 - strlen(tdefs[i].name); j>0; j--) + debug(" "); + i++; + if ((i % 6) == 0 || tdefs[i].name == NULL) + debug("\n"); + } } @@ -117,38 +148,33 @@ { char *symbol; uint64_t offset; - int x = cpu->cpu_id; + int x = cpu->cpu_id, i; if (gprs) { /* Special registers (pc, ...) first: */ symbol = get_symbol_name(&cpu->machine->symbol_context, cpu->pc, &offset); - debug("cpu%i: pc = 0x%08"PRIx32, x, (uint32_t)cpu->pc); + debug("cpu%i: pc = 0x%08"PRIx32, x, (uint32_t)cpu->pc); debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); - } -} - - -/* - * m68k_cpu_register_match(): - */ -void m68k_cpu_register_match(struct machine *m, char *name, - int writeflag, uint64_t *valuep, int *match_register) -{ - int cpunr = 0; - - /* CPU number: */ - /* TODO */ + for (i=0; icd.m68k.a[i]); + if ((i % 4) == 3) + debug("\n"); + } - /* Register name: */ - if (strcasecmp(name, "pc") == 0) { - if (writeflag) { - m->cpus[cpunr]->pc = *valuep; - } else - *valuep = m->cpus[cpunr]->pc; - *match_register = 1; + for (i=0; icd.m68k.d[i]); + if ((i % 4) == 3) + debug("\n"); + } } } @@ -241,64 +267,46 @@ print_two(ib, &len); - if (ib[0] == 0x48) { - if (ib[1] >= 0x40 && ib[1] <= 0x47) { - print_spaces(len); - debug("swap\td%i\n", ib[1] & 7); - } else if (ib[1] >= 0x48 && ib[1] <= 0x4f) { - print_spaces(len); - debug("bkpt\t#%i\n", ib[1] & 7); - } else { - print_spaces(len); - debug("UNIMPLEMENTED 0x%02x%02x\n", ib[0], ib[1]); - } - } else if (ib[0] == 0x4a) { - if (ib[1] == 0xfc) { - print_spaces(len); - debug("illegal\n"); - } else { - print_spaces(len); - debug("UNIMPLEMENTED 0x%02x%02x\n", ib[0], ib[1]); - } - } else if (ib[0] == 0x4e) { - if (ib[1] >= 0x40 && ib[1] <= 0x4f) { - print_spaces(len); - debug("trap\t#%i\n", ib[1] & 15); - } else if (ib[1] >= 0x50 && ib[1] <= 0x57) { - print_two(ib, &len); - print_spaces(len); - debug("linkw\t%%%s,#%i\n", m68k_aname[ib[1] & 7], - ((ib[2] << 8) + ib[3])); - } else if (ib[1] >= 0x58 && ib[1] <= 0x5f) { - print_spaces(len); - debug("unlk\t%%%s\n", m68k_aname[ib[1] & 7]); - } else if (ib[1] == 0x70) { - print_spaces(len); - debug("reset\n"); - } else if (ib[1] == 0x71) { - print_spaces(len); - debug("nop\n"); - } else if (ib[1] == 0x72) { - print_two(ib, &len); - print_spaces(len); - debug("stop\t#0x%04x\n", ((ib[2] << 8) + ib[3])); - } else if (ib[1] == 0x73) { - print_spaces(len); - debug("rte\n"); - } else if (ib[1] == 0x74) { - print_two(ib, &len); - print_spaces(len); - debug("rtd\t#0x%04x\n", ((ib[2] << 8) + ib[3])); - } else if (ib[1] == 0x75) { - print_spaces(len); - debug("rts\n"); - } else { - print_spaces(len); - debug("UNIMPLEMENTED 0x%02x%02x\n", ib[0], ib[1]); + switch (ib[0] >> 4) { + + case 0x4: + switch (ib[0] & 0xf) { + + case 0xe: + if (ib[1] >= 0x50 && ib[1] <= 0x57) { + print_two(ib, &len); + print_spaces(len); + debug("linkw\t%%%s,#%i\n", m68k_aname[ib[1] & 7], + ((ib[2] << 8) + ib[3])); + } else if (ib[1] >= 0x58 && ib[1] <= 0x5f) { + print_spaces(len); + debug("unlk\t%%%s\n", m68k_aname[ib[1] & 7]); + } else if (ib[1] == 0x71) { + print_spaces(len); + debug("nop\n"); + } else if (ib[1] == 0x73) { + print_spaces(len); + debug("rte\n"); + } else if (ib[1] == 0x74) { + print_two(ib, &len); + print_spaces(len); + debug("rtd\t#0x%04x\n", ((ib[2] << 8) + ib[3])); + } else if (ib[1] == 0x75) { + print_spaces(len); + debug("rts\n"); + } else { + print_spaces(len); + debug("UNIMPLEMENTED\n"); + } + break; + + default:print_spaces(len); + debug("UNIMPLEMENTED\n"); } - } else { - print_spaces(len); - debug("UNIMPLEMENTED 0x%02x%02x\n", ib[0], ib[1]); + break; + + default:print_spaces(len); + debug("UNIMPLEMENTED\n"); } return len;