--- trunk/src/emul.c 2007/10/08 16:21:17 34 +++ trunk/src/emul.c 2007/10/08 16:22:32 42 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: emul.c,v 1.278 2007/02/10 14:37:38 debug Exp $ + * $Id: emul.c,v 1.297 2007/06/15 17:02:37 debug Exp $ * * Emulation startup and misc. routines. */ @@ -52,14 +52,11 @@ #include "misc.h" #include "net.h" #include "settings.h" -#include "sgi_arcbios.h" #include "timer.h" +#include "useremul.h" #include "x11.h" -/* #define ISO_DEBUG */ - - extern int extra_argc; extern char **extra_argv; @@ -71,39 +68,26 @@ extern int old_instruction_trace; extern int old_quiet_mode; extern int quiet_mode; - -extern struct emul *debugger_emul; -extern struct diskimage *diskimages[]; - -static char *diskimage_types[] = DISKIMAGE_TYPES; - - -static void print_separator(void) -{ - int i = 79; - while (i-- > 0) - debug("-"); - debug("\n"); -} +extern int native_code_translation_enabled; /* - * add_dump_points(): + * add_breakpoints(): * * Take the strings breakpoint_string[] and convert to addresses * (and store them in breakpoint_addr[]). * * TODO: This function should be moved elsewhere. */ -static void add_dump_points(struct machine *m) +static void add_breakpoints(struct machine *m) { int i; int string_flag; uint64_t dp; - for (i=0; in_breakpoints; i++) { + for (i=0; ibreakpoints.n; i++) { string_flag = 0; - dp = strtoull(m->breakpoint_string[i], NULL, 0); + dp = strtoull(m->breakpoints.string[i], NULL, 0); /* * If conversion resulted in 0, then perhaps it is a @@ -112,12 +96,13 @@ if (dp == 0) { uint64_t addr; int res = get_symbol_addr(&m->symbol_context, - m->breakpoint_string[i], &addr); + m->breakpoints.string[i], &addr); if (!res) { fprintf(stderr, "ERROR! Breakpoint '%s' could not be" " parsed\n", - m->breakpoint_string[i]); + m->breakpoints.string[i]); + exit(1); } else { dp = addr; string_flag = 1; @@ -134,11 +119,11 @@ dp |= 0xffffffff00000000ULL; } - m->breakpoint_addr[i] = dp; + m->breakpoints.addr[i] = dp; debug("breakpoint %i: 0x%llx", i, (long long)dp); if (string_flag) - debug(" (%s)", m->breakpoint_string[i]); + debug(" (%s)", m->breakpoints.string[i]); debug("\n"); } } @@ -154,635 +139,6 @@ /* - * iso_load_bootblock(): - * - * Try to load a kernel from an ISO 9660 disk image. iso_type is 1 for - * "CD001" (standard), 2 for "CDW01" (ECMA), and 3 for "CDROM" (Sierra). - * - * TODO: This function uses too many magic offsets and so on; it should be - * cleaned up some day. - * - * Returns 1 on success, 0 on failure. - */ -static int iso_load_bootblock(struct machine *m, struct cpu *cpu, - int disk_id, int disk_type, int iso_type, unsigned char *buf, - int *n_loadp, char ***load_namesp) -{ - char str[35]; - int filenr, i, ofs, dirlen, res = 0, res2, iadd = DEBUG_INDENTATION; - int found_dir; - uint64_t dirofs; - uint64_t fileofs, filelen; - unsigned char *dirbuf = NULL, *dp; - unsigned char *match_entry = NULL; - char *p, *filename_orig; - char *filename = strdup(cpu->machine->boot_kernel_filename); - unsigned char *filebuf = NULL; - char *tmpfname = NULL; - char **new_array; - int tmpfile_handle; - - if (filename == NULL) { - fatal("out of memory\n"); - exit(1); - } - filename_orig = filename; - - debug("ISO9660 boot:\n"); - debug_indentation(iadd); - - /* Volume ID: */ - ofs = iso_type == 3? 48 : 40; - memcpy(str, buf + ofs, sizeof(str)); - str[32] = '\0'; i = 31; - while (i >= 0 && str[i]==' ') - str[i--] = '\0'; - if (str[0]) - debug("\"%s\"", str); - else { - /* System ID: */ - ofs = iso_type == 3? 16 : 8; - memcpy(str, buf + ofs, sizeof(str)); - str[32] = '\0'; i = 31; - while (i >= 0 && str[i]==' ') - str[i--] = '\0'; - if (str[0]) - debug("\"%s\"", str); - else - debug("(no ID)"); - } - - debug(":%s\n", filename); - - - /* - * Traverse the directory structure to find the kernel. - */ - - dirlen = buf[0x84] + 256*buf[0x85] + 65536*buf[0x86]; - if (dirlen != buf[0x8b] + 256*buf[0x8a] + 65536*buf[0x89]) - fatal("WARNING: Root directory length mismatch?\n"); - - dirofs = (int64_t)(buf[0x8c] + (buf[0x8d] << 8) + (buf[0x8e] << 16) + - ((uint64_t)buf[0x8f] << 24)) * 2048; - -#ifdef ISO_DEBUG - debug("root = %i bytes at 0x%llx\n", dirlen, (long long)dirofs); -#endif - - dirbuf = malloc(dirlen); - if (dirbuf == NULL) { - fatal("out of memory in iso_load_bootblock()\n"); - exit(1); - } - - res2 = diskimage_access(m, disk_id, disk_type, 0, dirofs, dirbuf, - dirlen); - if (!res2) { - fatal("Couldn't read the disk image. Aborting.\n"); - goto ret; - } - - found_dir = 1; /* Assume root dir */ - dp = dirbuf; filenr = 1; - p = NULL; - while (dp < dirbuf + dirlen) { - size_t i, nlen = dp[0]; - int x = dp[2] + (dp[3] << 8) + (dp[4] << 16) + - ((uint64_t)dp[5] << 24); - int y = dp[6] + (dp[7] << 8); - char direntry[65]; - - dp += 8; - - /* - * As long as there is an \ or / in the filename, then we - * have not yet found the directory. - */ - p = strchr(filename, '/'); - if (p == NULL) - p = strchr(filename, '\\'); - -#ifdef ISO_DEBUG - debug("%i%s: %i, %i, \"", filenr, filenr == found_dir? - " [CURRENT]" : "", x, y); -#endif - for (i=0; i 2047) { - dirofs = (dirofs | 2047) + 1; - /* debug("realign dirofs = 0x%llx\n", dirofs); */ - } - - res2 = diskimage_access(m, disk_id, disk_type, 0, dirofs, - dirbuf, 256); - if (!res2) { - fatal("Couldn't read the disk image. Aborting.\n"); - goto ret; - } - - dp = dirbuf; - len = dp[0]; - if (len < 2) - break; - - /* - * TODO: Actually parse the directory entry! - * - * Haha, this must be rewritten. - */ - for (i=32; i= 2) { - fatal("Error: Too many HFS partitions found! TODO\n"); - return 0; - } - - return 0; -} - - -/* - * load_bootblock(): - * - * For some emulation modes, it is possible to boot from a harddisk image by - * loading a bootblock from a specific disk offset into memory, and executing - * that, instead of requiring a separate kernel file. It is then up to the - * bootblock to load a kernel. - * - * Returns 1 on success, 0 on failure. - */ -static int load_bootblock(struct machine *m, struct cpu *cpu, - int *n_loadp, char ***load_namesp) -{ - int boot_disk_id, boot_disk_type = 0, n_blocks, res, readofs, - iso_type, retval = 0; - unsigned char minibuf[0x20]; - unsigned char *bootblock_buf; - uint64_t bootblock_offset, base_offset; - uint64_t bootblock_loadaddr, bootblock_pc; - - boot_disk_id = diskimage_bootdev(m, &boot_disk_type); - if (boot_disk_id < 0) - return 0; - - base_offset = diskimage_get_baseoffset(m, boot_disk_id, boot_disk_type); - - switch (m->machine_type) { - - case MACHINE_DREAMCAST: - if (!diskimage_is_a_cdrom(cpu->machine, boot_disk_id, - boot_disk_type)) { - fatal("The Dreamcast emulation mode can only boot" - " from CD images, not from other disk types.\n"); - exit(1); - } - - bootblock_buf = malloc(32768); - if (bootblock_buf == NULL) { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - - debug("loading Dreamcast IP.BIN from %s id %i\n", - diskimage_types[boot_disk_type], boot_disk_id); - - res = diskimage_access(m, boot_disk_id, boot_disk_type, - 0, base_offset, bootblock_buf, 0x8000); - if (!res) { - fatal("Couldn't read the disk image. Aborting.\n"); - return 0; - } - - if (strncmp((char *)bootblock_buf, "SEGA ", 5) != 0) { - fatal("This is not a Dreamcast IP.BIN header.\n"); - free(bootblock_buf); - return 0; - } - - /* Store IP.BIN at 0x8c008000, and set entry point. */ - store_buf(cpu, 0x8c008000, (char *)bootblock_buf, 32768); - cpu->pc = 0x8c008300; - - /* Remember the name of the file to boot (1ST_READ.BIN): */ - if (cpu->machine->boot_kernel_filename == NULL || - cpu->machine->boot_kernel_filename[0] == '\0') { - int i = 0x60; - while (i < 0x70) { - if (bootblock_buf[i] == ' ') - bootblock_buf[i] = 0; - i ++; - } - cpu->machine->boot_kernel_filename = strdup( - (char *)bootblock_buf + 0x60); - } - - debug("boot filename: %s\n", - cpu->machine->boot_kernel_filename); - - free(bootblock_buf); - - break; - - case MACHINE_PMAX: - /* - * The first few bytes of a disk contains information about - * where the bootblock(s) are located. (These are all 32-bit - * little-endian words.) - * - * Offset 0x10 = load address - * 0x14 = initial PC value - * 0x18 = nr of 512-byte blocks to read - * 0x1c = offset on disk to where the bootblocks - * are (in 512-byte units) - * 0x20 = nr of blocks to read... - * 0x24 = offset... - * - * nr of blocks to read and offset are repeated until nr of - * blocks to read is zero. - */ - res = diskimage_access(m, boot_disk_id, boot_disk_type, 0, 0, - minibuf, sizeof(minibuf)); - - bootblock_loadaddr = minibuf[0x10] + (minibuf[0x11] << 8) - + (minibuf[0x12] << 16) + ((uint64_t)minibuf[0x13] << 24); - - /* Convert loadaddr to uncached: */ - if ((bootblock_loadaddr & 0xf0000000ULL) != 0x80000000 && - (bootblock_loadaddr & 0xf0000000ULL) != 0xa0000000) { - fatal("\nWARNING! Weird load address 0x%08"PRIx32 - " for SCSI id %i.\n\n", - (uint32_t)bootblock_loadaddr, boot_disk_id); - if (bootblock_loadaddr == 0) { - fatal("I'm assuming that this is _not_ a " - "DEC bootblock.\nAre you sure you are" - " booting from the correct disk?\n"); - exit(1); - } - } - - bootblock_loadaddr &= 0x0fffffffULL; - bootblock_loadaddr |= 0xffffffffa0000000ULL; - - bootblock_pc = minibuf[0x14] + (minibuf[0x15] << 8) - + (minibuf[0x16] << 16) + ((uint64_t)minibuf[0x17] << 24); - - bootblock_pc &= 0x0fffffffULL; - bootblock_pc |= 0xffffffffa0000000ULL; - cpu->pc = bootblock_pc; - - debug("DEC boot: loadaddr=0x%08x, pc=0x%08x", - (int)bootblock_loadaddr, (int)bootblock_pc); - - readofs = 0x18; - - for (;;) { - res = diskimage_access(m, boot_disk_id, boot_disk_type, - 0, readofs, minibuf, sizeof(minibuf)); - if (!res) { - fatal("Couldn't read the disk image. " - "Aborting.\n"); - return 0; - } - - n_blocks = minibuf[0] + (minibuf[1] << 8) - + (minibuf[2] << 16) + ((uint64_t)minibuf[3] << 24); - - bootblock_offset = (minibuf[4] + (minibuf[5] << 8) + - (minibuf[6]<<16) + ((uint64_t)minibuf[7]<<24)) * 512; - - if (n_blocks < 1) - break; - - debug(readofs == 0x18? ": %i" : " + %i", n_blocks); - - if (n_blocks * 512 > 65536) - fatal("\nWARNING! Unusually large bootblock " - "(%i bytes)\n\n", n_blocks * 512); - - bootblock_buf = malloc(n_blocks * 512); - if (bootblock_buf == NULL) { - fprintf(stderr, "out of memory in " - "load_bootblock()\n"); - exit(1); - } - - res = diskimage_access(m, boot_disk_id, boot_disk_type, - 0, bootblock_offset, bootblock_buf, n_blocks * 512); - if (!res) { - fatal("WARNING: could not load bootblocks from" - " disk offset 0x%llx\n", - (long long)bootblock_offset); - } - - store_buf(cpu, bootblock_loadaddr, - (char *)bootblock_buf, n_blocks * 512); - - bootblock_loadaddr += 512*n_blocks; - free(bootblock_buf); - readofs += 8; - } - - debug(readofs == 0x18? ": no blocks?\n" : " blocks\n"); - return 1; - } - - - /* - * Try reading a kernel manually from the disk. The code here - * does not rely on machine-dependent boot blocks etc. - */ - /* ISO9660: (0x800 bytes at 0x8000 + base_offset) */ - bootblock_buf = malloc(0x800); - if (bootblock_buf == NULL) { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - - res = diskimage_access(m, boot_disk_id, boot_disk_type, - 0, base_offset + 0x8000, bootblock_buf, 0x800); - if (!res) { - fatal("Couldn't read the disk image. Aborting.\n"); - return 0; - } - - iso_type = 0; - if (strncmp((char *)bootblock_buf+1, "CD001", 5) == 0) - iso_type = 1; - if (strncmp((char *)bootblock_buf+1, "CDW01", 5) == 0) - iso_type = 2; - if (strncmp((char *)bootblock_buf+1, "CDROM", 5) == 0) - iso_type = 3; - - if (iso_type != 0) { - /* - * If the user specified a kernel name, then load it from - * disk. - */ - if (cpu->machine->boot_kernel_filename == NULL || - cpu->machine->boot_kernel_filename[0] == '\0') - fatal("\nISO9660 filesystem, but no kernel " - "specified? (Use the -j option.)\n"); - else - retval = iso_load_bootblock(m, cpu, boot_disk_id, - boot_disk_type, iso_type, bootblock_buf, - n_loadp, load_namesp); - } - - if (retval != 0) - goto ret_ok; - - /* Apple parition table: */ - res = diskimage_access(m, boot_disk_id, boot_disk_type, - 0, 0x0, bootblock_buf, 0x800); - if (!res) { - fatal("Couldn't read the disk image. Aborting.\n"); - return 0; - } - if (bootblock_buf[0x000] == 'E' && bootblock_buf[0x001] == 'R' && - bootblock_buf[0x200] == 'P' && bootblock_buf[0x201] == 'M') { - if (cpu->machine->boot_kernel_filename == NULL || - cpu->machine->boot_kernel_filename[0] == '\0') - fatal("\nApple partition table, but no kernel " - "specified? (Use the -j option.)\n"); - else - retval = apple_load_bootblock(m, cpu, boot_disk_id, - boot_disk_type, n_loadp, load_namesp); - } - -ret_ok: - free(bootblock_buf); - return retval; -} - - -/* * emul_new(): * * Returns a reasonably initialized struct emul. @@ -790,19 +146,11 @@ struct emul *emul_new(char *name, int id) { struct emul *e; - e = malloc(sizeof(struct emul)); - if (e == NULL) { - fprintf(stderr, "out of memory in emul_new()\n"); - exit(1); - } + CHECK_ALLOCATION(e = malloc(sizeof(struct emul))); memset(e, 0, sizeof(struct emul)); - e->path = malloc(15); - if (e->path == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(e->path = malloc(15)); snprintf(e->path, 15, "emul[%i]", id); e->settings = settings_new(); @@ -818,12 +166,7 @@ e->next_serial_nr = 1; if (name != NULL) { - e->name = strdup(name); - if (e->name == NULL) { - fprintf(stderr, "out of memory in emul_new()\n"); - exit(1); - } - + CHECK_ALLOCATION(e->name = strdup(name)); settings_add(e->settings, "name", 0, SETTINGS_TYPE_STRING, SETTINGS_FORMAT_STRING, (void *) &e->name); @@ -878,15 +221,10 @@ m = machine_new(name, e, e->n_machines); m->serial_nr = (e->next_serial_nr ++); - i = e->n_machines; + i = e->n_machines ++; - e->n_machines ++; - e->machines = realloc(e->machines, - sizeof(struct machine *) * e->n_machines); - if (e->machines == NULL) { - fprintf(stderr, "emul_add_machine(): out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(e->machines = realloc(e->machines, + sizeof(struct machine *) * e->n_machines)); e->machines[i] = m; @@ -1081,20 +419,11 @@ /* TODO: This should be moved elsewhere... */ if (m->machine_type == MACHINE_BEBOX) m->ncpus = 2; - else if (m->machine_type == MACHINE_ARC && - m->machine_subtype == MACHINE_ARC_NEC_R96) - m->ncpus = 2; - else if (m->machine_type == MACHINE_ARC && - m->machine_subtype == MACHINE_ARC_NEC_R98) - m->ncpus = 4; else m->ncpus = 1; } - m->cpus = malloc(sizeof(struct cpu *) * m->ncpus); - if (m->cpus == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + + CHECK_ALLOCATION(m->cpus = malloc(sizeof(struct cpu *) * m->ncpus)); memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus); debug("cpu0"); @@ -1111,18 +440,6 @@ } debug("\n"); -#if 0 - /* Special case: The Playstation Portable has an additional CPU: */ - if (m->machine_type == MACHINE_PSP) { - debug("cpu%i: ", m->ncpus); - m->cpus[m->ncpus] = cpu_new(m->memory, m, - 0 /* use 0 here to show info with debug() */, - "Allegrex" /* TODO */); - debug("\n"); - m->ncpus ++; - } -#endif - if (m->use_random_bootstrap_cpu) m->bootstrap_cpu = random() % m->ncpus; else @@ -1136,16 +453,17 @@ m->userland_emul, NULL, NULL, NULL); switch (m->arch) { -#ifdef ENABLE_ALPHA + case ARCH_ALPHA: cpu->memory_rw = alpha_userland_memory_rw; break; -#endif - default:cpu->memory_rw = userland_memory_rw; + + default: + cpu->memory_rw = userland_memory_rw; } } - if (m->use_x11) + if (m->x11_md.in_use) x11_init(m); /* Fill memory with random bytes: */ @@ -1214,8 +532,11 @@ fread(buf, 1, sizeof(buf), tmp_f); if (buf[0]==0x1f && buf[1]==0x8b) { size_t zzlen = strlen(name_to_load)*2 + 100; - char *zz = malloc(zzlen); + char *zz; + + CHECK_ALLOCATION(zz = malloc(zzlen)); debug("gunziping %s\n", name_to_load); + /* * gzip header found. If this was a file * extracted from, say, a CDROM image, then it @@ -1232,8 +553,9 @@ } else { /* gunzip into new temp file: */ int tmpfile_handle; - char *new_temp_name = - strdup("/tmp/gxemul.XXXXXXXXXXXX"); + char *new_temp_name; + CHECK_ALLOCATION(new_temp_name = + strdup("/tmp/gxemul.XXXXXXXXXXXX")); tmpfile_handle = mkstemp(new_temp_name); close(tmpfile_handle); snprintf(zz, zzlen, "gunzip -c '%s' > " @@ -1247,48 +569,6 @@ fclose(tmp_f); } - /* - * Ugly (but usable) hack for Playstation Portable: If the - * filename ends with ".pbp" and the file contains an ELF - * header, then extract the ELF file into a temporary file. - */ - if (strlen(name_to_load) > 4 && strcasecmp(name_to_load + - strlen(name_to_load) - 4, ".pbp") == 0 && - (tmp_f = fopen(name_to_load, "r")) != NULL) { - off_t filesize, j, found=0; - unsigned char *buf; - fseek(tmp_f, 0, SEEK_END); - filesize = ftello(tmp_f); - fseek(tmp_f, 0, SEEK_SET); - buf = malloc(filesize); - if (buf == NULL) { - fprintf(stderr, "out of memory while trying" - " to read %s\n", name_to_load); - exit(1); - } - fread(buf, 1, filesize, tmp_f); - fclose(tmp_f); - /* Search for the ELF header, from offset 1 (!): */ - for (j=1; jpc &= 0xfffffffc; break; - case ARCH_AVR: - cpu->pc &= 0xfffff; - if (cpu->pc & 1) { - fatal("AVR: lowest bit of pc set: TODO\n"); + case ARCH_M88K: + if (cpu->pc & 3) { + fatal("M88K: lowest bits of pc set: TODO\n"); exit(1); } - break; - - case ARCH_RCA180X: - cpu->pc &= 0xffff; - break; - - case ARCH_M68K: + cpu->pc &= 0xfffffffc; break; case ARCH_MIPS: @@ -1367,10 +640,6 @@ case ARCH_SPARC: break; - case ARCH_TRANSPUTER: - cpu->pc &= 0xffffffffULL; - break; - default: fatal("emul_machine_setup(): Internal error: " "Unimplemented arch %i\n", m->arch); @@ -1414,8 +683,8 @@ m->cpus[i]->running = 0; } - /* Add PC dump points: */ - add_dump_points(m); + /* Parse and add breakpoints: */ + add_breakpoints(m); /* TODO: This is MIPS-specific! */ if (m->machine_type == MACHINE_PMAX && @@ -1435,43 +704,38 @@ case ARCH_ARM: /* ARM cpus aren't 64-bit: */ - debug("0x%08x", (int)entrypoint); - break; - - case ARCH_AVR: - /* Atmel AVR uses a 16-bit or 22-bit program counter: */ - debug("0x%04x", (int)entrypoint); + debug("0x%08"PRIx32, (uint32_t) entrypoint); break; case ARCH_MIPS: if (cpu->is_32bit) { - debug("0x%08x", (int)m->cpus[ - m->bootstrap_cpu]->pc); + debug("0x%08"PRIx32, (uint32_t) + m->cpus[m->bootstrap_cpu]->pc); if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) - debug(" (gp=0x%08x)", (int)m->cpus[ - m->bootstrap_cpu]->cd.mips.gpr[ + debug(" (gp=0x%08"PRIx32")", (uint32_t) + m->cpus[m->bootstrap_cpu]->cd.mips.gpr[ MIPS_GPR_GP]); } else { - debug("0x%016llx", (long long)m->cpus[ - m->bootstrap_cpu]->pc); + debug("0x%016"PRIx64, (uint64_t) + m->cpus[m->bootstrap_cpu]->pc); if (cpu->cd.mips.gpr[MIPS_GPR_GP] != 0) - debug(" (gp=0x%016llx)", (long long) + debug(" (gp=0x%016"PRIx64")", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_GP]); } break; case ARCH_PPC: if (cpu->cd.ppc.bits == 32) - debug("0x%08x", (int)entrypoint); + debug("0x%08"PRIx32, (uint32_t) entrypoint); else - debug("0x%016llx", (long long)entrypoint); + debug("0x%016"PRIx64, (uint64_t) entrypoint); break; default: if (cpu->is_32bit) - debug("0x%08x", (int)cpu->pc); + debug("0x%08"PRIx32, (uint32_t) cpu->pc); else - debug("0x%016llx", (long long)cpu->pc); + debug("0x%016"PRIx64, (uint64_t) cpu->pc); } debug("\n"); @@ -1597,7 +861,7 @@ if (emul->n_debugger_cmds > 0) { int j; if (i == 0) - print_separator(); + print_separator_line(); for (j = 0; j < emul->n_debugger_cmds; j ++) { debug("> %s\n", emul->debugger_cmds[j]); debugger_execute_cmd(emul->debugger_cmds[j], @@ -1606,7 +870,7 @@ } } - print_separator(); + print_separator_line(); debug("\n"); @@ -1648,29 +912,27 @@ /* * MAIN LOOP: * - * Run all emulations in parallel, running each machine in - * each emulation. + * Run all emulations in parallel, running instructions from each + * cpu in each machine in each emulation. */ while (go) { + struct cpu *bootcpu = emuls[0]->machines[0]->cpus[ + emuls[0]->machines[0]->bootstrap_cpu]; + go = 0; /* Flush X11 and serial console output every now and then: */ - if (emuls[0]->machines[0]->ninstrs > - emuls[0]->machines[0]->ninstrs_flush + (1<<19)) { + if (bootcpu->ninstrs > bootcpu->ninstrs_flush + (1<<19)) { x11_check_event(emuls, n_emuls); console_flush(); - emuls[0]->machines[0]->ninstrs_flush = - emuls[0]->machines[0]->ninstrs; + bootcpu->ninstrs_flush = bootcpu->ninstrs; } - if (emuls[0]->machines[0]->ninstrs > - emuls[0]->machines[0]->ninstrs_show + (1<<25)) { - emuls[0]->machines[0]->ninstrs_since_gettimeofday += - (emuls[0]->machines[0]->ninstrs - - emuls[0]->machines[0]->ninstrs_show); + if (bootcpu->ninstrs > bootcpu->ninstrs_show + (1<<25)) { + bootcpu->ninstrs_since_gettimeofday += + (bootcpu->ninstrs - bootcpu->ninstrs_show); cpu_show_cycles(emuls[0]->machines[0], 0); - emuls[0]->machines[0]->ninstrs_show = - emuls[0]->machines[0]->ninstrs; + bootcpu->ninstrs_show = bootcpu->ninstrs; } if (single_step == ENTER_SINGLE_STEPPING) { @@ -1693,10 +955,6 @@ e = emuls[i]; for (j=0; jn_machines; j++) { - if (e->machines[j]->gdb.port > 0) - debugger_gdb_check_incoming( - e->machines[j]); - anything = machine_run(e->machines[j]); if (anything) go = 1; @@ -1727,7 +985,7 @@ n = 0; for (i=0; in_machines; j++) - if (emuls[i]->machines[j]->use_x11) + if (emuls[i]->machines[j]->x11_md.in_use) n++; if (n > 0) { printf("Press enter to quit.\n");