--- trunk/src/main.c 2007/10/08 16:20:58 32 +++ trunk/src/main.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2003-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: main.c,v 1.284 2006/09/19 10:50:08 debug Exp $ + * $Id: main.c,v 1.293 2007/02/05 16:49:05 debug Exp $ */ #include @@ -59,6 +59,8 @@ char **extra_argv; char *progname; +size_t dyntrans_cache_size = DEFAULT_DYNTRANS_CACHE_SIZE; +int native_code_translation_enabled = 0; int skip_srandom_call = 0; @@ -198,7 +200,7 @@ #ifdef VERSION printf(" " VERSION); #endif - printf(" Copyright (C) 2003-2006 Anders Gavare\n"); + printf(" Copyright (C) 2003-2007 Anders Gavare\n"); printf("Read the source code and/or documentation for " "other Copyright messages.\n"); @@ -236,6 +238,8 @@ printf(" gH;S; set geometry to H heads and S" " sectors-per-track\n"); printf(" i IDE\n"); + printf(" oOFS; set base offset to OFS (for ISO9660" + " filesystems)\n"); printf(" r read-only (don't allow changes to the" " file)\n"); printf(" s SCSI\n"); @@ -243,7 +247,7 @@ printf(" 0-7 force a specific ID\n"); printf(" -G port listen to gdb remote connections on this port\n"); printf(" -I hz set the main cpu frequency to hz (not used by " - "all combinations\n of machines and guest OSes)"); + "all combinations\n of machines and guest OSes)\n"); printf(" -i display each instruction as it is executed\n"); printf(" -J disable dyntrans instruction combinations\n"); printf(" -j name set the name of the kernel; for DECstation " @@ -284,6 +288,7 @@ printf(" d disable statistics gathering at " "startup\n"); printf(" o overwrite instead of append\n"); + printf(" -T halt on non-existant memory accesses\n"); printf(" -t show function trace tree\n"); printf(" -U enable slow_serial_interrupts_hack_for_linux\n"); #ifdef WITH_X11 @@ -306,12 +311,18 @@ #endif printf("\nGeneral options:\n"); +#ifdef UNSTABLE_DEVEL + printf(" -b enable native code generation\n"); + printf(" -B disable native code generation\n"); +#endif printf(" -c cmd add cmd as a command to run before starting " "the simulation\n"); printf(" -D skip the srandom call at startup\n"); printf(" -H display a list of possible CPU and " "machine types\n"); printf(" -h display this help message\n"); + printf(" -k n set dyntrans translation caches to n MB (default" + " size is %i MB)\n", DEFAULT_DYNTRANS_CACHE_SIZE / 1048576); printf(" -K force the debugger to be entered at the end " "of a simulation\n"); printf(" -q quiet mode (don't print startup messages)\n"); @@ -352,7 +363,10 @@ struct machine *m = emul_add_machine(emul, "default"); char *opts = - "C:c:Dd:E:e:G:HhI:iJj:KM:Nn:Oo:p:QqRrSs:tU" +#ifdef UNSTABLE_DEVEL + "bB" +#endif + "C:c:Dd:E:e:G:HhI:iJj:k:KM:Nn:Oo:p:QqRrSs:TtU" #ifdef UNSTABLE_DEVEL "u:" #endif @@ -364,6 +378,19 @@ while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { +#ifdef UNSTABLE_DEVEL + case 'b': +#ifndef NATIVE_CODE_GENERATION + printf("-b is not available on this host arch.\n"); + exit(1); +#else + native_code_translation_enabled = 1; + break; +#endif + case 'B': + native_code_translation_enabled = 0; + break; +#endif /* UNSTABLE_DEVEL */ case 'C': m->cpu_name = strdup(optarg); msopts = 1; @@ -448,6 +475,14 @@ } msopts = 1; break; + case 'k': + dyntrans_cache_size = atoi(optarg) * 1048576; + if (dyntrans_cache_size < 1) { + fprintf(stderr, "The dyntrans cache size must" + " be at least 1 MB.\n"); + exit(1); + } + break; case 'K': force_debugger_at_exit = 1; break; @@ -511,6 +546,11 @@ break; case 's': machine_statistics_init(m, optarg); + native_code_translation_enabled = 0; + msopts = 1; + break; + case 'T': + m->halt_on_nonexistant_memaccess = 1; msopts = 1; break; case 't': @@ -707,6 +747,17 @@ int i; +#ifdef USE_PROFIL + uint16_t samples[0x100000]; + memset(samples, 0, sizeof(samples)); + profil((char *)samples, sizeof(samples), (vm_offset_t) 0x400000, 8192); +#endif + +#ifndef NATIVE_CODE_GENERATION + native_code_translation_enabled = 0; +#endif + + progname = argv[0]; @@ -727,8 +778,14 @@ settings_add(global_settings, "false", 0, SETTINGS_TYPE_INT, SETTINGS_FORMAT_BOOL, (void *)&constant_false); + /* Read-only settings: */ + settings_add(global_settings, "native_code_translation_enabled", 0, + SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, + (void *)&native_code_translation_enabled); settings_add(global_settings, "single_step", 0, SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&single_step); + + /* Read/write settings: */ settings_add(global_settings, "force_debugger_at_exit", 1, SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&force_debugger_at_exit); @@ -753,7 +810,7 @@ /* Allocate space for a simple emul setup: */ n_emuls = 1; - emuls[0] = emul_new(NULL); + emuls[0] = emul_new(NULL, 0); if (emuls[0] == NULL) { fprintf(stderr, "out of memory\n"); exit(1); @@ -774,7 +831,7 @@ #ifdef VERSION debug(" " VERSION); #endif - debug(" Copyright (C) 2003-2006 Anders Gavare\n"); + debug(" Copyright (C) 2003-2007 Anders Gavare\n"); debug("Read the source code and/or documentation for " "other Copyright messages.\n\n"); @@ -831,7 +888,7 @@ } emuls[n_emuls - 1] = - emul_create_from_configfile(s); + emul_create_from_configfile(s, n_emuls - 1); snprintf(tmpstr, sizeof(tmpstr), "emul[%i]", n_emuls-1); settings_add(global_settings, tmpstr, 1, @@ -869,6 +926,18 @@ settings_remove_all(global_settings); settings_destroy(global_settings); +#ifdef USE_PROFIL +{ + int i; + FILE *f = fopen("output.txt", "w"); + for (i=0; i