25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: emul.c,v 1.203 2005/06/03 07:39:27 debug Exp $ |
* $Id: emul.c,v 1.235 2005/10/26 14:37:02 debug Exp $ |
29 |
* |
* |
30 |
* Emulation startup and misc. routines. |
* Emulation startup and misc. routines. |
31 |
*/ |
*/ |
46 |
#include "debugger.h" |
#include "debugger.h" |
47 |
#include "device.h" |
#include "device.h" |
48 |
#include "diskimage.h" |
#include "diskimage.h" |
49 |
|
#include "exec_elf.h" |
50 |
#include "machine.h" |
#include "machine.h" |
51 |
#include "memory.h" |
#include "memory.h" |
52 |
#include "mips_cpu_types.h" |
#include "mips_cpu_types.h" |
435 |
|
|
436 |
|
|
437 |
/* |
/* |
438 |
|
* apple_load_bootblock(): |
439 |
|
* |
440 |
|
* Try to load a kernel from a disk image with an Apple Partition Table. |
441 |
|
* |
442 |
|
* TODO: This function uses too many magic offsets and so on; it should be |
443 |
|
* cleaned up some day. See http://www.awprofessional.com/articles/ |
444 |
|
* article.asp?p=376123&seqNum=3&rl=1 for some info on the Apple |
445 |
|
* partition format. |
446 |
|
* |
447 |
|
* Returns 1 on success, 0 on failure. |
448 |
|
*/ |
449 |
|
static int apple_load_bootblock(struct machine *m, struct cpu *cpu, |
450 |
|
int disk_id, int disk_type, int *n_loadp, char ***load_namesp) |
451 |
|
{ |
452 |
|
unsigned char buf[0x8000]; |
453 |
|
int res, partnr, n_partitions = 0, n_hfs_partitions = 0; |
454 |
|
uint64_t hfs_start, hfs_length; |
455 |
|
|
456 |
|
res = diskimage_access(m, disk_id, disk_type, 0, 0x0, buf, sizeof(buf)); |
457 |
|
if (!res) { |
458 |
|
fatal("apple_load_bootblock: couldn't read the disk " |
459 |
|
"image. Aborting.\n"); |
460 |
|
return 0; |
461 |
|
} |
462 |
|
|
463 |
|
partnr = 0; |
464 |
|
do { |
465 |
|
int start, length; |
466 |
|
int ofs = 0x200 * (partnr + 1); |
467 |
|
if (partnr == 0) |
468 |
|
n_partitions = buf[ofs + 7]; |
469 |
|
start = (buf[ofs + 8] << 24) + (buf[ofs + 9] << 16) + |
470 |
|
(buf[ofs + 10] << 8) + buf[ofs + 11]; |
471 |
|
length = (buf[ofs + 12] << 24) + (buf[ofs + 13] << 16) + |
472 |
|
(buf[ofs + 14] << 8) + buf[ofs + 15]; |
473 |
|
|
474 |
|
debug("partition %i: '%s', type '%s', start %i, length %i\n", |
475 |
|
partnr, buf + ofs + 0x10, buf + ofs + 0x30, |
476 |
|
start, length); |
477 |
|
|
478 |
|
if (strcmp((char *)buf + ofs + 0x30, "Apple_HFS") == 0) { |
479 |
|
n_hfs_partitions ++; |
480 |
|
hfs_start = 512 * start; |
481 |
|
hfs_length = 512 * length; |
482 |
|
} |
483 |
|
|
484 |
|
/* Any more partitions? */ |
485 |
|
partnr ++; |
486 |
|
} while (partnr < n_partitions); |
487 |
|
|
488 |
|
if (n_hfs_partitions == 0) { |
489 |
|
fatal("Error: No HFS partition found! TODO\n"); |
490 |
|
return 0; |
491 |
|
} |
492 |
|
if (n_hfs_partitions >= 2) { |
493 |
|
fatal("Error: Too many HFS partitions found! TODO\n"); |
494 |
|
return 0; |
495 |
|
} |
496 |
|
|
497 |
|
return 0; |
498 |
|
} |
499 |
|
|
500 |
|
|
501 |
|
/* |
502 |
* load_bootblock(): |
* load_bootblock(): |
503 |
* |
* |
504 |
* For some emulation modes, it is possible to boot from a harddisk image by |
* For some emulation modes, it is possible to boot from a harddisk image by |
650 |
|
|
651 |
/* |
/* |
652 |
* Try reading a kernel manually from the disk. The code here |
* Try reading a kernel manually from the disk. The code here |
653 |
* does not rely on machine-dependant boot blocks etc. |
* does not rely on machine-dependent boot blocks etc. |
654 |
*/ |
*/ |
655 |
/* ISO9660: (0x800 bytes at 0x8000) */ |
/* ISO9660: (0x800 bytes at 0x8000) */ |
656 |
bootblock_buf = malloc(0x800); |
bootblock_buf = malloc(0x800); |
687 |
n_loadp, load_namesp); |
n_loadp, load_namesp); |
688 |
} |
} |
689 |
|
|
690 |
|
if (retval != 0) |
691 |
|
goto ret_ok; |
692 |
|
|
693 |
|
/* Apple parition table: */ |
694 |
|
res = diskimage_access(m, boot_disk_id, boot_disk_type, |
695 |
|
0, 0x0, bootblock_buf, 0x800); |
696 |
|
if (!res) { |
697 |
|
fatal("Couldn't read the disk image. Aborting.\n"); |
698 |
|
return 0; |
699 |
|
} |
700 |
|
if (bootblock_buf[0x000] == 'E' && bootblock_buf[0x001] == 'R' && |
701 |
|
bootblock_buf[0x200] == 'P' && bootblock_buf[0x201] == 'M') { |
702 |
|
/* We can't load a kernel if the name |
703 |
|
isn't specified. */ |
704 |
|
if (cpu->machine->boot_kernel_filename == NULL || |
705 |
|
cpu->machine->boot_kernel_filename[0] == '\0') |
706 |
|
fatal("\nApple partition table, but no kernel " |
707 |
|
"specified? (Use the -j option.)\n"); |
708 |
|
else |
709 |
|
retval = apple_load_bootblock(m, cpu, boot_disk_id, |
710 |
|
boot_disk_type, n_loadp, load_namesp); |
711 |
|
} |
712 |
|
|
713 |
|
ret_ok: |
714 |
free(bootblock_buf); |
free(bootblock_buf); |
715 |
return retval; |
return retval; |
716 |
} |
} |
734 |
|
|
735 |
/* Sane default values: */ |
/* Sane default values: */ |
736 |
e->n_machines = 0; |
e->n_machines = 0; |
737 |
|
e->next_serial_nr = 1; |
738 |
|
|
739 |
if (name != NULL) { |
if (name != NULL) { |
740 |
e->name = strdup(name); |
e->name = strdup(name); |
797 |
|
|
798 |
len += 1048576 * m->memory_offset_in_mb; |
len += 1048576 * m->memory_offset_in_mb; |
799 |
|
|
800 |
/* NOTE/TODO: magic 12MB end of load program area */ |
/* |
801 |
|
* NOTE/TODO: magic 12MB end of load program area |
802 |
|
* |
803 |
|
* Hm. This breaks the old FreeBSD/MIPS snapshots... |
804 |
|
*/ |
805 |
|
#if 0 |
806 |
arcbios_add_memory_descriptor(cpu, |
arcbios_add_memory_descriptor(cpu, |
807 |
0x60000 + m->memory_offset_in_mb * 1048576, |
0x60000 + m->memory_offset_in_mb * 1048576, |
808 |
start-0x60000 - m->memory_offset_in_mb * 1048576, |
start-0x60000 - m->memory_offset_in_mb * 1048576, |
809 |
ARCBIOS_MEM_FreeMemory); |
ARCBIOS_MEM_FreeMemory); |
810 |
|
#endif |
811 |
arcbios_add_memory_descriptor(cpu, |
arcbios_add_memory_descriptor(cpu, |
812 |
start, len, ARCBIOS_MEM_LoadedProgram); |
start, len, ARCBIOS_MEM_LoadedProgram); |
813 |
|
|
928 |
|
|
929 |
m->cpu_family = cpu_family_ptr_by_number(m->arch); |
m->cpu_family = cpu_family_ptr_by_number(m->arch); |
930 |
|
|
931 |
|
if (m->arch == ARCH_ALPHA) |
932 |
|
m->arch_pagesize = 8192; |
933 |
|
|
934 |
|
if (m->arch != ARCH_MIPS) |
935 |
|
m->bintrans_enable = 0; |
936 |
|
|
937 |
machine_memsize_fix(m); |
machine_memsize_fix(m); |
938 |
|
|
939 |
/* |
/* |
954 |
debug(" (offset by %iMB)", m->memory_offset_in_mb); |
debug(" (offset by %iMB)", m->memory_offset_in_mb); |
955 |
memory_amount += 1048576 * m->memory_offset_in_mb; |
memory_amount += 1048576 * m->memory_offset_in_mb; |
956 |
} |
} |
957 |
m->memory = memory_new(memory_amount); |
m->memory = memory_new(memory_amount, m->arch); |
958 |
if (m->machine_type != MACHINE_USERLAND) |
if (m->machine_type != MACHINE_USERLAND) |
959 |
debug("\n"); |
debug("\n"); |
960 |
|
|
996 |
} |
} |
997 |
debug("\n"); |
debug("\n"); |
998 |
|
|
999 |
|
#if 0 |
1000 |
|
/* Special case: The Playstation Portable has an additional CPU: */ |
1001 |
|
if (m->machine_type == MACHINE_PSP) { |
1002 |
|
debug("cpu%i: ", m->ncpus); |
1003 |
|
m->cpus[m->ncpus] = cpu_new(m->memory, m, |
1004 |
|
0 /* use 0 here to show info with debug() */, |
1005 |
|
"Allegrex" /* TODO */); |
1006 |
|
if (m->bintrans_enable) |
1007 |
|
bintrans_init_cpu(m->cpus[m->ncpus]); |
1008 |
|
debug("\n"); |
1009 |
|
m->ncpus ++; |
1010 |
|
} |
1011 |
|
#endif |
1012 |
|
|
1013 |
if (m->use_random_bootstrap_cpu) |
if (m->use_random_bootstrap_cpu) |
1014 |
m->bootstrap_cpu = random() % m->ncpus; |
m->bootstrap_cpu = random() % m->ncpus; |
1015 |
else |
else |
1021 |
if (m->userland_emul != NULL) { |
if (m->userland_emul != NULL) { |
1022 |
useremul_name_to_useremul(cpu, |
useremul_name_to_useremul(cpu, |
1023 |
m->userland_emul, NULL, NULL, NULL); |
m->userland_emul, NULL, NULL, NULL); |
1024 |
cpu->memory_rw = userland_memory_rw; |
|
1025 |
|
switch (m->arch) { |
1026 |
|
#ifdef ENABLE_ALPHA |
1027 |
|
case ARCH_ALPHA: |
1028 |
|
cpu->memory_rw = alpha_userland_memory_rw; |
1029 |
|
break; |
1030 |
|
#endif |
1031 |
|
default:cpu->memory_rw = userland_memory_rw; |
1032 |
|
} |
1033 |
} |
} |
1034 |
|
|
1035 |
if (m->use_x11) |
if (m->use_x11) |
1090 |
} |
} |
1091 |
|
|
1092 |
/* |
/* |
1093 |
* Another special hack for temporary files; running gunzip |
* gzipped files are automagically gunzipped: |
1094 |
* on them, if they have a gzip header. TODO: Change this |
* NOTE/TODO: This isn't secure. system() is used. |
|
* into some kind of generic support for gzipped files! |
|
1095 |
*/ |
*/ |
1096 |
tmp_f = fopen(name_to_load, "r"); |
tmp_f = fopen(name_to_load, "r"); |
1097 |
if (tmp_f != NULL) { |
if (tmp_f != NULL) { |
1099 |
memset(buf, 0, sizeof(buf)); |
memset(buf, 0, sizeof(buf)); |
1100 |
fread(buf, 1, sizeof(buf), tmp_f); |
fread(buf, 1, sizeof(buf), tmp_f); |
1101 |
if (buf[0]==0x1f && buf[1]==0x8b) { |
if (buf[0]==0x1f && buf[1]==0x8b) { |
1102 |
char *zz = malloc(strlen(name_to_load)*2 + 100); |
size_t zzlen = strlen(name_to_load)*2 + 100; |
1103 |
|
char *zz = malloc(zzlen); |
1104 |
debug("gunziping %s\n", name_to_load); |
debug("gunziping %s\n", name_to_load); |
1105 |
sprintf(zz, "mv %s %s.gz", name_to_load, |
/* |
1106 |
name_to_load); |
* gzip header found. If this was a file |
1107 |
system(zz); |
* extracted from, say, a CDROM image, then it |
1108 |
sprintf(zz, "gunzip %s.gz", name_to_load); |
* already has a temporary name. Otherwise we |
1109 |
system(zz); |
* have to gunzip into a temporary file. |
1110 |
|
*/ |
1111 |
|
if (remove_after_load) { |
1112 |
|
snprintf(zz, zzlen, "mv %s %s.gz", |
1113 |
|
name_to_load, name_to_load); |
1114 |
|
system(zz); |
1115 |
|
snprintf(zz, zzlen, "gunzip %s.gz", |
1116 |
|
name_to_load); |
1117 |
|
system(zz); |
1118 |
|
} else { |
1119 |
|
/* gunzip into new temp file: */ |
1120 |
|
int tmpfile_handle; |
1121 |
|
char *new_temp_name = |
1122 |
|
strdup("/tmp/gxemul.XXXXXXXXXXXX"); |
1123 |
|
tmpfile_handle = mkstemp(new_temp_name); |
1124 |
|
close(tmpfile_handle); |
1125 |
|
snprintf(zz, zzlen, "gunzip -c '%s' > " |
1126 |
|
"%s", name_to_load, new_temp_name); |
1127 |
|
system(zz); |
1128 |
|
name_to_load = new_temp_name; |
1129 |
|
remove_after_load = 1; |
1130 |
|
} |
1131 |
free(zz); |
free(zz); |
1132 |
} |
} |
1133 |
fclose(tmp_f); |
fclose(tmp_f); |
1134 |
} |
} |
1135 |
|
|
1136 |
|
/* |
1137 |
|
* Ugly (but usable) hack for Playstation Portable: If the |
1138 |
|
* filename ends with ".pbp" and the file contains an ELF |
1139 |
|
* header, then extract the ELF file into a temporary file. |
1140 |
|
*/ |
1141 |
|
if (strlen(name_to_load) > 4 && strcasecmp(name_to_load + |
1142 |
|
strlen(name_to_load) - 4, ".pbp") == 0 && |
1143 |
|
(tmp_f = fopen(name_to_load, "r")) != NULL) { |
1144 |
|
off_t filesize, j, found=0; |
1145 |
|
unsigned char *buf; |
1146 |
|
fseek(tmp_f, 0, SEEK_END); |
1147 |
|
filesize = ftello(tmp_f); |
1148 |
|
fseek(tmp_f, 0, SEEK_SET); |
1149 |
|
buf = malloc(filesize); |
1150 |
|
if (buf == NULL) { |
1151 |
|
fprintf(stderr, "out of memory while trying" |
1152 |
|
" to read %s\n", name_to_load); |
1153 |
|
exit(1); |
1154 |
|
} |
1155 |
|
fread(buf, 1, filesize, tmp_f); |
1156 |
|
fclose(tmp_f); |
1157 |
|
/* Search for the ELF header, from offset 1 (!): */ |
1158 |
|
for (j=1; j<filesize - 4; j++) |
1159 |
|
if (memcmp(buf + j, ELFMAG, SELFMAG) == 0) { |
1160 |
|
found = j; |
1161 |
|
break; |
1162 |
|
} |
1163 |
|
if (found != 0) { |
1164 |
|
int tmpfile_handle; |
1165 |
|
char *new_temp_name = |
1166 |
|
strdup("/tmp/gxemul.XXXXXXXXXXXX"); |
1167 |
|
debug("extracting ELF from %s (offset 0x%x)\n", |
1168 |
|
name_to_load, (int)found); |
1169 |
|
tmpfile_handle = mkstemp(new_temp_name); |
1170 |
|
write(tmpfile_handle, buf + found, |
1171 |
|
filesize - found); |
1172 |
|
close(tmpfile_handle); |
1173 |
|
name_to_load = new_temp_name; |
1174 |
|
remove_after_load = 1; |
1175 |
|
} |
1176 |
|
} |
1177 |
|
|
1178 |
/* Special things required _before_ loading the file: */ |
/* Special things required _before_ loading the file: */ |
1179 |
switch (m->arch) { |
switch (m->arch) { |
1180 |
case ARCH_X86: |
case ARCH_X86: |
1208 |
cpu->pc = entrypoint; |
cpu->pc = entrypoint; |
1209 |
|
|
1210 |
switch (m->arch) { |
switch (m->arch) { |
1211 |
|
|
1212 |
|
case ARCH_ALPHA: |
1213 |
|
/* For position-independent code: */ |
1214 |
|
cpu->cd.alpha.r[ALPHA_T12] = cpu->pc; |
1215 |
|
break; |
1216 |
|
|
1217 |
|
case ARCH_ARM: |
1218 |
|
cpu->pc &= 0xfffffffc; |
1219 |
|
cpu->cd.arm.r[ARM_PC] = cpu->pc; |
1220 |
|
break; |
1221 |
|
|
1222 |
|
case ARCH_AVR: |
1223 |
|
cpu->pc &= 0xfffff; |
1224 |
|
if (cpu->pc & 1) { |
1225 |
|
fatal("AVR: lowest bit of pc set: TODO\n"); |
1226 |
|
exit(1); |
1227 |
|
} |
1228 |
|
break; |
1229 |
|
|
1230 |
|
case ARCH_HPPA: |
1231 |
|
break; |
1232 |
|
|
1233 |
|
case ARCH_I960: |
1234 |
|
break; |
1235 |
|
|
1236 |
|
case ARCH_IA64: |
1237 |
|
break; |
1238 |
|
|
1239 |
|
case ARCH_M68K: |
1240 |
|
break; |
1241 |
|
|
1242 |
case ARCH_MIPS: |
case ARCH_MIPS: |
1243 |
if ((cpu->pc >> 32) == 0 |
if ((cpu->pc >> 32) == 0 |
1244 |
&& (cpu->pc & 0x80000000ULL)) |
&& (cpu->pc & 0x80000000ULL)) |
1257 |
spec/x458.html for more info. */ |
spec/x458.html for more info. */ |
1258 |
cpu->cd.ppc.gpr[2] = toc; |
cpu->cd.ppc.gpr[2] = toc; |
1259 |
/* TODO */ |
/* TODO */ |
1260 |
|
if (cpu->cd.ppc.bits == 32) |
1261 |
|
cpu->pc &= 0xffffffffULL; |
1262 |
break; |
break; |
1263 |
|
|
1264 |
case ARCH_ALPHA: |
case ARCH_SH: |
1265 |
case ARCH_HPPA: |
if (cpu->cd.sh.bits == 32) |
1266 |
case ARCH_SPARC: |
cpu->pc &= 0xffffffffULL; |
1267 |
case ARCH_URISC: |
cpu->pc &= ~1; |
1268 |
break; |
break; |
1269 |
|
|
1270 |
case ARCH_ARM: |
case ARCH_SPARC: |
|
cpu->pc &= 0xffffffff; |
|
1271 |
break; |
break; |
1272 |
|
|
1273 |
case ARCH_X86: |
case ARCH_X86: |
1339 |
if (m->machine_type == MACHINE_DEC && |
if (m->machine_type == MACHINE_DEC && |
1340 |
cpu->cd.mips.cpu_type.mmu_model == MMU3K) |
cpu->cd.mips.cpu_type.mmu_model == MMU3K) |
1341 |
add_symbol_name(&m->symbol_context, |
add_symbol_name(&m->symbol_context, |
1342 |
0x9fff0000, 0x10000, "r2k3k_cache", 0); |
0x9fff0000, 0x10000, "r2k3k_cache", 0, 0); |
1343 |
|
|
1344 |
symbol_recalc_sizes(&m->symbol_context); |
symbol_recalc_sizes(&m->symbol_context); |
1345 |
|
|
1354 |
|
|
1355 |
debug("starting cpu%i at ", m->bootstrap_cpu); |
debug("starting cpu%i at ", m->bootstrap_cpu); |
1356 |
switch (m->arch) { |
switch (m->arch) { |
1357 |
|
|
1358 |
|
case ARCH_ARM: |
1359 |
|
/* ARM cpus aren't 64-bit: */ |
1360 |
|
debug("0x%08x", (int)entrypoint); |
1361 |
|
break; |
1362 |
|
|
1363 |
|
case ARCH_AVR: |
1364 |
|
/* Atmel AVR uses a 16-bit or 22-bit program counter: */ |
1365 |
|
debug("0x%04x", (int)entrypoint); |
1366 |
|
break; |
1367 |
|
|
1368 |
case ARCH_MIPS: |
case ARCH_MIPS: |
1369 |
if (cpu->cd.mips.cpu_type.isa_level < 3 || |
if (cpu->is_32bit) { |
|
cpu->cd.mips.cpu_type.isa_level == 32) { |
|
1370 |
debug("0x%08x", (int)m->cpus[ |
debug("0x%08x", (int)m->cpus[ |
1371 |
m->bootstrap_cpu]->pc); |
m->bootstrap_cpu]->pc); |
1372 |
if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) |
if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) |
1381 |
cpu->cd.mips.gpr[MIPS_GPR_GP]); |
cpu->cd.mips.gpr[MIPS_GPR_GP]); |
1382 |
} |
} |
1383 |
break; |
break; |
1384 |
|
|
1385 |
case ARCH_PPC: |
case ARCH_PPC: |
1386 |
if (cpu->cd.ppc.bits == 32) |
if (cpu->cd.ppc.bits == 32) |
1387 |
debug("0x%08x", (int)entrypoint); |
debug("0x%08x", (int)entrypoint); |
1388 |
else |
else |
1389 |
debug("0x%016llx", (long long)entrypoint); |
debug("0x%016llx", (long long)entrypoint); |
1390 |
break; |
break; |
|
case ARCH_ARM: |
|
|
/* ARM cpus aren't 64-bit: */ |
|
|
debug("0x%08x", (int)entrypoint); |
|
|
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]; |
|
|
} |
|
1391 |
|
|
|
sprintf(tmps, "0x%%0%illx", cpu->cd.urisc.wordlen / 4); |
|
|
debug(tmps, (long long)entrypoint); |
|
|
cpu->pc = entrypoint; |
|
|
} |
|
|
break; |
|
1392 |
case ARCH_X86: |
case ARCH_X86: |
1393 |
debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS], |
debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS], |
1394 |
(long long)cpu->pc); |
(long long)cpu->pc); |
1395 |
break; |
break; |
1396 |
|
|
1397 |
default: |
default: |
1398 |
debug("0x%016llx", (long long)cpu->pc); |
debug("0x%016llx", (long long)cpu->pc); |
1399 |
} |
} |
1453 |
debug("Simple setup...\n"); |
debug("Simple setup...\n"); |
1454 |
debug_indentation(iadd); |
debug_indentation(iadd); |
1455 |
|
|
1456 |
/* Create a network: */ |
/* Create a simple network: */ |
1457 |
emul->net = net_init(emul, NET_INIT_FLAG_GATEWAY, |
emul->net = net_init(emul, NET_INIT_FLAG_GATEWAY, |
1458 |
"10.0.0.0", 8); |
"10.0.0.0", 8, NULL, 0, 0); |
1459 |
} else { |
} else { |
1460 |
/* Userland pseudo-machine: */ |
/* Userland pseudo-machine: */ |
1461 |
debug("Syscall emulation (userland-only) setup...\n"); |
debug("Syscall emulation (userland-only) setup...\n"); |
1562 |
if (e == NULL) |
if (e == NULL) |
1563 |
continue; |
continue; |
1564 |
for (j=0; j<e->n_machines; j++) |
for (j=0; j<e->n_machines; j++) |
1565 |
cpu_run_init(e, e->machines[j]); |
cpu_run_init(e->machines[j]); |
1566 |
} |
} |
1567 |
|
|
1568 |
|
/* TODO: Generalize: */ |
1569 |
|
if (emuls[0]->machines[0]->show_trace_tree) |
1570 |
|
cpu_functioncall_trace(emuls[0]->machines[0]->cpus[0], |
1571 |
|
emuls[0]->machines[0]->cpus[0]->pc); |
1572 |
|
|
1573 |
/* |
/* |
1574 |
* MAIN LOOP: |
* MAIN LOOP: |
1575 |
* |
* |
1602 |
if (e == NULL) |
if (e == NULL) |
1603 |
continue; |
continue; |
1604 |
for (j=0; j<e->n_machines; j++) |
for (j=0; j<e->n_machines; j++) |
1605 |
cpu_run_deinit(e, e->machines[j]); |
cpu_run_deinit(e->machines[j]); |
1606 |
} |
} |
1607 |
|
|
1608 |
/* force_debugger_at_exit flag set? Then enter the debugger: */ |
/* force_debugger_at_exit flag set? Then enter the debugger: */ |