1 |
/* |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $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 $ |
29 |
*/ |
*/ |
30 |
|
|
31 |
#include <stdio.h> |
#include <stdio.h> |
59 |
char **extra_argv; |
char **extra_argv; |
60 |
char *progname; |
char *progname; |
61 |
|
|
62 |
|
size_t dyntrans_cache_size = DEFAULT_DYNTRANS_CACHE_SIZE; |
63 |
|
int native_code_translation_enabled = 0; |
64 |
int skip_srandom_call = 0; |
int skip_srandom_call = 0; |
65 |
|
|
66 |
|
|
200 |
#ifdef VERSION |
#ifdef VERSION |
201 |
printf(" " VERSION); |
printf(" " VERSION); |
202 |
#endif |
#endif |
203 |
printf(" Copyright (C) 2003-2006 Anders Gavare\n"); |
printf(" Copyright (C) 2003-2007 Anders Gavare\n"); |
204 |
printf("Read the source code and/or documentation for " |
printf("Read the source code and/or documentation for " |
205 |
"other Copyright messages.\n"); |
"other Copyright messages.\n"); |
206 |
|
|
238 |
printf(" gH;S; set geometry to H heads and S" |
printf(" gH;S; set geometry to H heads and S" |
239 |
" sectors-per-track\n"); |
" sectors-per-track\n"); |
240 |
printf(" i IDE\n"); |
printf(" i IDE\n"); |
241 |
|
printf(" oOFS; set base offset to OFS (for ISO9660" |
242 |
|
" filesystems)\n"); |
243 |
printf(" r read-only (don't allow changes to the" |
printf(" r read-only (don't allow changes to the" |
244 |
" file)\n"); |
" file)\n"); |
245 |
printf(" s SCSI\n"); |
printf(" s SCSI\n"); |
247 |
printf(" 0-7 force a specific ID\n"); |
printf(" 0-7 force a specific ID\n"); |
248 |
printf(" -G port listen to gdb remote connections on this port\n"); |
printf(" -G port listen to gdb remote connections on this port\n"); |
249 |
printf(" -I hz set the main cpu frequency to hz (not used by " |
printf(" -I hz set the main cpu frequency to hz (not used by " |
250 |
"all combinations\n of machines and guest OSes)"); |
"all combinations\n of machines and guest OSes)\n"); |
251 |
printf(" -i display each instruction as it is executed\n"); |
printf(" -i display each instruction as it is executed\n"); |
252 |
printf(" -J disable dyntrans instruction combinations\n"); |
printf(" -J disable dyntrans instruction combinations\n"); |
253 |
printf(" -j name set the name of the kernel; for DECstation " |
printf(" -j name set the name of the kernel; for DECstation " |
288 |
printf(" d disable statistics gathering at " |
printf(" d disable statistics gathering at " |
289 |
"startup\n"); |
"startup\n"); |
290 |
printf(" o overwrite instead of append\n"); |
printf(" o overwrite instead of append\n"); |
291 |
|
printf(" -T halt on non-existant memory accesses\n"); |
292 |
printf(" -t show function trace tree\n"); |
printf(" -t show function trace tree\n"); |
293 |
printf(" -U enable slow_serial_interrupts_hack_for_linux\n"); |
printf(" -U enable slow_serial_interrupts_hack_for_linux\n"); |
294 |
#ifdef WITH_X11 |
#ifdef WITH_X11 |
311 |
#endif |
#endif |
312 |
|
|
313 |
printf("\nGeneral options:\n"); |
printf("\nGeneral options:\n"); |
314 |
|
#ifdef UNSTABLE_DEVEL |
315 |
|
printf(" -b enable native code generation\n"); |
316 |
|
printf(" -B disable native code generation\n"); |
317 |
|
#endif |
318 |
printf(" -c cmd add cmd as a command to run before starting " |
printf(" -c cmd add cmd as a command to run before starting " |
319 |
"the simulation\n"); |
"the simulation\n"); |
320 |
printf(" -D skip the srandom call at startup\n"); |
printf(" -D skip the srandom call at startup\n"); |
321 |
printf(" -H display a list of possible CPU and " |
printf(" -H display a list of possible CPU and " |
322 |
"machine types\n"); |
"machine types\n"); |
323 |
printf(" -h display this help message\n"); |
printf(" -h display this help message\n"); |
324 |
|
printf(" -k n set dyntrans translation caches to n MB (default" |
325 |
|
" size is %i MB)\n", DEFAULT_DYNTRANS_CACHE_SIZE / 1048576); |
326 |
printf(" -K force the debugger to be entered at the end " |
printf(" -K force the debugger to be entered at the end " |
327 |
"of a simulation\n"); |
"of a simulation\n"); |
328 |
printf(" -q quiet mode (don't print startup messages)\n"); |
printf(" -q quiet mode (don't print startup messages)\n"); |
363 |
struct machine *m = emul_add_machine(emul, "default"); |
struct machine *m = emul_add_machine(emul, "default"); |
364 |
|
|
365 |
char *opts = |
char *opts = |
366 |
"C:c:Dd:E:e:G:HhI:iJj:KM:Nn:Oo:p:QqRrSs:tU" |
#ifdef UNSTABLE_DEVEL |
367 |
|
"bB" |
368 |
|
#endif |
369 |
|
"C:c:Dd:E:e:G:HhI:iJj:k:KM:Nn:Oo:p:QqRrSs:TtU" |
370 |
#ifdef UNSTABLE_DEVEL |
#ifdef UNSTABLE_DEVEL |
371 |
"u:" |
"u:" |
372 |
#endif |
#endif |
378 |
|
|
379 |
while ((ch = getopt(argc, argv, opts)) != -1) { |
while ((ch = getopt(argc, argv, opts)) != -1) { |
380 |
switch (ch) { |
switch (ch) { |
381 |
|
#ifdef UNSTABLE_DEVEL |
382 |
|
case 'b': |
383 |
|
#ifndef NATIVE_CODE_GENERATION |
384 |
|
printf("-b is not available on this host arch.\n"); |
385 |
|
exit(1); |
386 |
|
#else |
387 |
|
native_code_translation_enabled = 1; |
388 |
|
break; |
389 |
|
#endif |
390 |
|
case 'B': |
391 |
|
native_code_translation_enabled = 0; |
392 |
|
break; |
393 |
|
#endif /* UNSTABLE_DEVEL */ |
394 |
case 'C': |
case 'C': |
395 |
m->cpu_name = strdup(optarg); |
m->cpu_name = strdup(optarg); |
396 |
msopts = 1; |
msopts = 1; |
475 |
} |
} |
476 |
msopts = 1; |
msopts = 1; |
477 |
break; |
break; |
478 |
|
case 'k': |
479 |
|
dyntrans_cache_size = atoi(optarg) * 1048576; |
480 |
|
if (dyntrans_cache_size < 1) { |
481 |
|
fprintf(stderr, "The dyntrans cache size must" |
482 |
|
" be at least 1 MB.\n"); |
483 |
|
exit(1); |
484 |
|
} |
485 |
|
break; |
486 |
case 'K': |
case 'K': |
487 |
force_debugger_at_exit = 1; |
force_debugger_at_exit = 1; |
488 |
break; |
break; |
546 |
break; |
break; |
547 |
case 's': |
case 's': |
548 |
machine_statistics_init(m, optarg); |
machine_statistics_init(m, optarg); |
549 |
|
native_code_translation_enabled = 0; |
550 |
|
msopts = 1; |
551 |
|
break; |
552 |
|
case 'T': |
553 |
|
m->halt_on_nonexistant_memaccess = 1; |
554 |
msopts = 1; |
msopts = 1; |
555 |
break; |
break; |
556 |
case 't': |
case 't': |
747 |
int i; |
int i; |
748 |
|
|
749 |
|
|
750 |
|
#ifdef USE_PROFIL |
751 |
|
uint16_t samples[0x100000]; |
752 |
|
memset(samples, 0, sizeof(samples)); |
753 |
|
profil((char *)samples, sizeof(samples), (vm_offset_t) 0x400000, 8192); |
754 |
|
#endif |
755 |
|
|
756 |
|
#ifndef NATIVE_CODE_GENERATION |
757 |
|
native_code_translation_enabled = 0; |
758 |
|
#endif |
759 |
|
|
760 |
|
|
761 |
progname = argv[0]; |
progname = argv[0]; |
762 |
|
|
763 |
|
|
778 |
settings_add(global_settings, "false", 0, SETTINGS_TYPE_INT, |
settings_add(global_settings, "false", 0, SETTINGS_TYPE_INT, |
779 |
SETTINGS_FORMAT_BOOL, (void *)&constant_false); |
SETTINGS_FORMAT_BOOL, (void *)&constant_false); |
780 |
|
|
781 |
|
/* Read-only settings: */ |
782 |
|
settings_add(global_settings, "native_code_translation_enabled", 0, |
783 |
|
SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, |
784 |
|
(void *)&native_code_translation_enabled); |
785 |
settings_add(global_settings, "single_step", 0, |
settings_add(global_settings, "single_step", 0, |
786 |
SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&single_step); |
SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&single_step); |
787 |
|
|
788 |
|
/* Read/write settings: */ |
789 |
settings_add(global_settings, "force_debugger_at_exit", 1, |
settings_add(global_settings, "force_debugger_at_exit", 1, |
790 |
SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, |
SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, |
791 |
(void *)&force_debugger_at_exit); |
(void *)&force_debugger_at_exit); |
810 |
|
|
811 |
/* Allocate space for a simple emul setup: */ |
/* Allocate space for a simple emul setup: */ |
812 |
n_emuls = 1; |
n_emuls = 1; |
813 |
emuls[0] = emul_new(NULL); |
emuls[0] = emul_new(NULL, 0); |
814 |
if (emuls[0] == NULL) { |
if (emuls[0] == NULL) { |
815 |
fprintf(stderr, "out of memory\n"); |
fprintf(stderr, "out of memory\n"); |
816 |
exit(1); |
exit(1); |
831 |
#ifdef VERSION |
#ifdef VERSION |
832 |
debug(" " VERSION); |
debug(" " VERSION); |
833 |
#endif |
#endif |
834 |
debug(" Copyright (C) 2003-2006 Anders Gavare\n"); |
debug(" Copyright (C) 2003-2007 Anders Gavare\n"); |
835 |
debug("Read the source code and/or documentation for " |
debug("Read the source code and/or documentation for " |
836 |
"other Copyright messages.\n\n"); |
"other Copyright messages.\n\n"); |
837 |
|
|
888 |
} |
} |
889 |
|
|
890 |
emuls[n_emuls - 1] = |
emuls[n_emuls - 1] = |
891 |
emul_create_from_configfile(s); |
emul_create_from_configfile(s, n_emuls - 1); |
892 |
|
|
893 |
snprintf(tmpstr, sizeof(tmpstr), "emul[%i]", n_emuls-1); |
snprintf(tmpstr, sizeof(tmpstr), "emul[%i]", n_emuls-1); |
894 |
settings_add(global_settings, tmpstr, 1, |
settings_add(global_settings, tmpstr, 1, |
926 |
settings_remove_all(global_settings); |
settings_remove_all(global_settings); |
927 |
settings_destroy(global_settings); |
settings_destroy(global_settings); |
928 |
|
|
929 |
|
#ifdef USE_PROFIL |
930 |
|
{ |
931 |
|
int i; |
932 |
|
FILE *f = fopen("output.txt", "w"); |
933 |
|
for (i=0; i<sizeof(samples) / sizeof(uint16_t); ++i) { |
934 |
|
if (samples[i] != 0) |
935 |
|
fprintf(f, "%i %p\n", samples[i], |
936 |
|
(void *) (size_t) (0x400000 + i * 16)); |
937 |
|
} |
938 |
|
} |
939 |
|
#endif |
940 |
|
|
941 |
return 0; |
return 0; |
942 |
} |
} |
943 |
|
|