25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: emul.c,v 1.211 2005/06/26 11:36:28 debug Exp $ |
* $Id: emul.c,v 1.225 2005/08/14 19:35:54 debug Exp $ |
29 |
* |
* |
30 |
* Emulation startup and misc. routines. |
* Emulation startup and misc. routines. |
31 |
*/ |
*/ |
709 |
|
|
710 |
len += 1048576 * m->memory_offset_in_mb; |
len += 1048576 * m->memory_offset_in_mb; |
711 |
|
|
712 |
/* NOTE/TODO: magic 12MB end of load program area */ |
/* |
713 |
|
* NOTE/TODO: magic 12MB end of load program area |
714 |
|
* |
715 |
|
* Hm. This breaks the old FreeBSD/MIPS snapshots... |
716 |
|
*/ |
717 |
|
#if 0 |
718 |
arcbios_add_memory_descriptor(cpu, |
arcbios_add_memory_descriptor(cpu, |
719 |
0x60000 + m->memory_offset_in_mb * 1048576, |
0x60000 + m->memory_offset_in_mb * 1048576, |
720 |
start-0x60000 - m->memory_offset_in_mb * 1048576, |
start-0x60000 - m->memory_offset_in_mb * 1048576, |
721 |
ARCBIOS_MEM_FreeMemory); |
ARCBIOS_MEM_FreeMemory); |
722 |
|
#endif |
723 |
arcbios_add_memory_descriptor(cpu, |
arcbios_add_memory_descriptor(cpu, |
724 |
start, len, ARCBIOS_MEM_LoadedProgram); |
start, len, ARCBIOS_MEM_LoadedProgram); |
725 |
|
|
840 |
|
|
841 |
m->cpu_family = cpu_family_ptr_by_number(m->arch); |
m->cpu_family = cpu_family_ptr_by_number(m->arch); |
842 |
|
|
843 |
|
if (m->arch == ARCH_ALPHA) |
844 |
|
m->arch_pagesize = 8192; |
845 |
|
|
846 |
if (m->arch != ARCH_MIPS) |
if (m->arch != ARCH_MIPS) |
847 |
m->bintrans_enable = 0; |
m->bintrans_enable = 0; |
848 |
|
|
866 |
debug(" (offset by %iMB)", m->memory_offset_in_mb); |
debug(" (offset by %iMB)", m->memory_offset_in_mb); |
867 |
memory_amount += 1048576 * m->memory_offset_in_mb; |
memory_amount += 1048576 * m->memory_offset_in_mb; |
868 |
} |
} |
869 |
m->memory = memory_new(memory_amount); |
m->memory = memory_new(memory_amount, m->arch); |
870 |
if (m->machine_type != MACHINE_USERLAND) |
if (m->machine_type != MACHINE_USERLAND) |
871 |
debug("\n"); |
debug("\n"); |
872 |
|
|
933 |
if (m->userland_emul != NULL) { |
if (m->userland_emul != NULL) { |
934 |
useremul_name_to_useremul(cpu, |
useremul_name_to_useremul(cpu, |
935 |
m->userland_emul, NULL, NULL, NULL); |
m->userland_emul, NULL, NULL, NULL); |
936 |
cpu->memory_rw = userland_memory_rw; |
|
937 |
|
switch (m->arch) { |
938 |
|
#ifdef ENABLE_ALPHA |
939 |
|
case ARCH_ALPHA: |
940 |
|
cpu->memory_rw = alpha_userland_memory_rw; |
941 |
|
break; |
942 |
|
#endif |
943 |
|
default:cpu->memory_rw = userland_memory_rw; |
944 |
|
} |
945 |
} |
} |
946 |
|
|
947 |
if (m->use_x11) |
if (m->use_x11) |
1141 |
break; |
break; |
1142 |
|
|
1143 |
case ARCH_ALPHA: |
case ARCH_ALPHA: |
1144 |
case ARCH_HPPA: |
/* For position-independant code: */ |
1145 |
|
cpu->cd.alpha.r[ALPHA_T12] = cpu->pc; |
1146 |
|
break; |
1147 |
|
|
1148 |
case ARCH_SPARC: |
case ARCH_SPARC: |
1149 |
case ARCH_URISC: |
break; |
1150 |
|
|
1151 |
|
case ARCH_IA64: |
1152 |
|
break; |
1153 |
|
|
1154 |
|
case ARCH_M68K: |
1155 |
break; |
break; |
1156 |
|
|
1157 |
case ARCH_ARM: |
case ARCH_ARM: |
1228 |
if (m->machine_type == MACHINE_DEC && |
if (m->machine_type == MACHINE_DEC && |
1229 |
cpu->cd.mips.cpu_type.mmu_model == MMU3K) |
cpu->cd.mips.cpu_type.mmu_model == MMU3K) |
1230 |
add_symbol_name(&m->symbol_context, |
add_symbol_name(&m->symbol_context, |
1231 |
0x9fff0000, 0x10000, "r2k3k_cache", 0); |
0x9fff0000, 0x10000, "r2k3k_cache", 0, 0); |
1232 |
|
|
1233 |
symbol_recalc_sizes(&m->symbol_context); |
symbol_recalc_sizes(&m->symbol_context); |
1234 |
|
|
1244 |
debug("starting cpu%i at ", m->bootstrap_cpu); |
debug("starting cpu%i at ", m->bootstrap_cpu); |
1245 |
switch (m->arch) { |
switch (m->arch) { |
1246 |
case ARCH_MIPS: |
case ARCH_MIPS: |
1247 |
if (cpu->cd.mips.cpu_type.isa_level < 3 || |
if (cpu->is_32bit) { |
|
cpu->cd.mips.cpu_type.isa_level == 32) { |
|
1248 |
debug("0x%08x", (int)m->cpus[ |
debug("0x%08x", (int)m->cpus[ |
1249 |
m->bootstrap_cpu]->pc); |
m->bootstrap_cpu]->pc); |
1250 |
if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) |
if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) |
1269 |
/* ARM cpus aren't 64-bit: */ |
/* ARM cpus aren't 64-bit: */ |
1270 |
debug("0x%08x", (int)entrypoint); |
debug("0x%08x", (int)entrypoint); |
1271 |
break; |
break; |
|
case ARCH_URISC: |
|
|
{ |
|
|
char tmps[100]; |
|
|
unsigned char buf[sizeof(uint64_t)]; |
|
|
|
|
|
cpu->memory_rw(cpu, m->memory, 0, buf, sizeof(buf), |
|
|
MEM_READ, CACHE_NONE | NO_EXCEPTIONS); |
|
|
|
|
|
entrypoint = 0; |
|
|
for (i=0; i<cpu->cd.urisc.wordlen/8; i++) { |
|
|
entrypoint <<= 8; |
|
|
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
|
|
entrypoint += buf[i]; |
|
|
else |
|
|
entrypoint += buf[cpu-> |
|
|
cd.urisc.wordlen/8 - 1 - i]; |
|
|
} |
|
|
|
|
|
snprintf(tmps, sizeof(tmps), "0x%%0%illx", |
|
|
cpu->cd.urisc.wordlen / 4); |
|
|
debug(tmps, (long long)entrypoint); |
|
|
cpu->pc = entrypoint; |
|
|
} |
|
|
break; |
|
1272 |
case ARCH_X86: |
case ARCH_X86: |
1273 |
debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS], |
debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS], |
1274 |
(long long)cpu->pc); |
(long long)cpu->pc); |
1441 |
if (e == NULL) |
if (e == NULL) |
1442 |
continue; |
continue; |
1443 |
for (j=0; j<e->n_machines; j++) |
for (j=0; j<e->n_machines; j++) |
1444 |
cpu_run_init(e, e->machines[j]); |
cpu_run_init(e->machines[j]); |
1445 |
} |
} |
1446 |
|
|
1447 |
|
/* TODO: Generalize: */ |
1448 |
|
if (emuls[0]->machines[0]->show_trace_tree) |
1449 |
|
cpu_functioncall_trace(emuls[0]->machines[0]->cpus[0], |
1450 |
|
emuls[0]->machines[0]->cpus[0]->pc); |
1451 |
|
|
1452 |
/* |
/* |
1453 |
* MAIN LOOP: |
* MAIN LOOP: |
1454 |
* |
* |
1481 |
if (e == NULL) |
if (e == NULL) |
1482 |
continue; |
continue; |
1483 |
for (j=0; j<e->n_machines; j++) |
for (j=0; j<e->n_machines; j++) |
1484 |
cpu_run_deinit(e, e->machines[j]); |
cpu_run_deinit(e->machines[j]); |
1485 |
} |
} |
1486 |
|
|
1487 |
/* force_debugger_at_exit flag set? Then enter the debugger: */ |
/* force_debugger_at_exit flag set? Then enter the debugger: */ |