--- trunk/src/machine.c 2007/10/08 16:20:18 27 +++ trunk/src/machine.c 2007/10/08 16:20:26 28 @@ -25,18 +25,13 @@ * SUCH DAMAGE. * * - * $Id: machine.c,v 1.673 2006/06/24 19:52:27 debug Exp $ + * $Id: machine.c,v 1.679 2006/07/16 13:32:25 debug Exp $ */ #include #include #include -#ifdef SOLARIS -/* TODO: is this strings vs string separation really necessary? */ -#include -#else #include -#endif #include #include @@ -93,9 +88,8 @@ m->machine_subtype = MACHINE_NONE; m->arch_pagesize = 4096; /* Should be overriden in emul.c for other pagesizes. */ - m->dyntrans_alignment_check = 1; m->prom_emulation = 1; - m->speed_tricks = 1; + m->allow_instruction_combinations = 1; m->byte_order_override = NO_BYTE_ORDER_OVERRIDE; m->boot_kernel_filename = ""; m->boot_string_argument = NULL; @@ -258,6 +252,79 @@ /* + * machine_statistics_init(): + * + * Initialize the parts of a machine struct that deal with instruction + * statistics gathering. + * + * Note: The fname argument contains "flags:filename". + */ +void machine_statistics_init(struct machine *machine, char *fname) +{ + int n_fields = 0; + char *pcolon = fname; + char *mode = "a"; /* Append by default */ + + machine->allow_instruction_combinations = 0; + + if (machine->statistics_fields != NULL) { + fprintf(stderr, "Only one -s option is allowed.\n"); + exit(1); + } + + machine->statistics_fields = malloc(MAX_STATISTICS_FIELDS + 1); + machine->statistics_enabled = 1; + + while (*pcolon && *pcolon != ':') + pcolon ++; + + if (*pcolon != ':') { + fprintf(stderr, "The syntax for the -s option is: " + "-s flags:filename\nYou omitted the flags. Run g" + "xemul -h for a list of available flags.\n"); + exit(1); + } + + while (*fname != ':') { + switch (*fname) { + + /* Type flags: */ + case 'v': + case 'i': + case 'p': + machine->statistics_fields[n_fields ++] = *fname; + if (n_fields >= MAX_STATISTICS_FIELDS) { + fprintf(stderr, "Internal error: Too many " + "statistics fields used. Increase " + "MAX_STATISTICS_FIELDS.\n"); + exit(1); + } + machine->statistics_fields[n_fields] = '\0'; + break; + + /* Optional flags: */ + case 'o': + mode = "w"; + break; + case 'd': + machine->statistics_enabled = 0; + break; + + default:fprintf(stderr, "Unknown flag '%c' used with the" + " -s option. Aborting.\n", *fname); + exit(1); + } + fname ++; + } + + fname ++; /* point to the filename after the colon */ + + machine->statistics_filename = strdup(fname); + machine->statistics_file = fopen(machine->statistics_filename, mode); +} + + +/* * machine_bus_register(): * * Registers a bus in a machine. @@ -917,8 +984,7 @@ for (i=0; irunning) { - int instrs_run = machine->cpu_family->run_instr( - machine->emul, cpus[i]); + int instrs_run = cpus[i]->run_instr(cpus[i]); if (i == 0) cpu0instrs += instrs_run; } @@ -927,12 +993,12 @@ /* * Hardware 'ticks': (clocks, interrupt sources...) * - * Here, cpu0instrs is the number of instructions - * executed on cpu0. (TODO: don't use cpu 0 for this, - * use some kind of "mainbus" instead.) + * Here, cpu0instrs is the number of instructions executed on cpu0. + * + * TODO: This should be redesigned into some "mainbus" stuff instead! */ - machine->ncycles += cpu0instrs; + machine->ninstrs += cpu0instrs; for (te=0; ten_tick_entries; te++) { machine->ticks_till_next[te] -= cpu0instrs;