66 static int skip_srandom_call = 0;
80 static int debug_indent = 0;
81 static int debug_currently_at_start_of_line = 1;
89 static void va_debug(va_list argp,
const char *fmt)
100 if (debug_currently_at_start_of_line) {
101 for (i=0; i<debug_indent; i++)
107 debug_currently_at_start_of_line = 0;
108 if (*s ==
'\n' || *s ==
'\r')
109 debug_currently_at_start_of_line = 1;
122 debug_indent += diff;
123 if (debug_indent < 0)
124 fprintf(stderr,
"WARNING: debug_indent less than 0!\n");
172 if (arg == NULL || strncmp(arg,
"W@", 2) != 0) {
173 fprintf(stderr,
"-W is for internal use by gxemul," 174 " not for manual use.\n");
205 cerr <<
"Having memory leaks counts as failure to run the tests!\n";
214 fprintf(stderr,
"internal_w(): UNIMPLEMENTED arg = '%s'\n",
228 static void usage(
int longusage)
232 printf(
"Read the source code and/or documentation for " 233 "other Copyright messages.\n");
235 printf(
"\nUsage: %s [options] -e name [additional components and files [...]]\n",
progname);
236 printf(
" or %s [options] configfile\n",
progname);
241 printf(
"\nOptions:\n");
242 printf(
" -B Enable snapshotting (reverse stepping support).\n");
243 printf(
" -H Display a list of available machine templates.\n");
244 printf(
" -e name Start with a machine based on template 'name'.\n");
245 printf(
" -q Quiet mode (suppress debug messages).\n");
246 printf(
" -V Start up in interactive debugging mode, paused.\n");
251 printf(
"\nLegacy usage: %s [machine, other, and general options] [file " 253 printf(
" or %s [general options] @configfile\n",
progname);
255 printf(
"\nRun %s -h for help on command line options.\n",
260 printf(
"\nThe following are options for the Old framework:\n");
262 printf(
"\nLegacy usage: %s [machine, other, and general options] [file " 264 printf(
" or %s [general options] @configfile\n",
progname);
266 printf(
"\nMachine selection options:\n");
267 printf(
" -E t try to emulate machine type t. (Use -H to get " 268 "a list of types.)\n");
269 printf(
" -e st try to emulate machine subtype st. (Use this " 272 printf(
"\nOther options:\n");
273 printf(
" -C x try to emulate a specific CPU. (Use -H to get a " 274 "list of types.)\n");
275 printf(
" -d fname add fname as a disk image. You can add \"xxx:\"" 277 printf(
" where xxx is one or more of the following:\n");
278 printf(
" b specifies that this is the boot" 280 printf(
" c CD-ROM\n");
282 printf(
" f FLOPPY\n");
283 printf(
" gH;S; set geometry to H heads and S" 284 " sectors-per-track\n");
286 printf(
" oOFS; set base offset to OFS (for ISO9660" 288 printf(
" r read-only (don't allow changes to the" 292 printf(
" V add an overlay\n");
293 printf(
" 0-7 force a specific ID\n");
294 printf(
" -I hz set the main cpu frequency to hz (not used by " 295 "all combinations\n of machines and guest OSes)\n");
296 printf(
" -i display each instruction as it is executed\n");
297 printf(
" -J disable dyntrans instruction combinations\n");
298 printf(
" -j name set the name of the kernel; for DECstation " 299 "emulation, this passes\n the name to the bootloader," 301 printf(
" -j netbsd (NetBSD/pmax) " 302 "-j bsd (OpenBSD/pmax)\n");
303 printf(
" -j vmsprite (Sprite/pmax) " 304 "-j vmunix (Ultrix/RISC)\n");
305 printf(
" For other emulation modes, if the boot disk is an" 306 " ISO9660\n filesystem, -j sets the name of the" 307 " kernel to load.\n");
308 printf(
" -M m emulate m MBs of physical RAM\n");
309 printf(
" -N display nr of instructions/second average, at" 310 " regular intervals\n");
311 printf(
" -n nr set nr of CPUs (for SMP experiments)\n");
312 printf(
" -O force netboot (tftp instead of disk), even when" 314 " present (for DECstation, SGI, and ARC emulation)\n");
315 printf(
" -o arg set the boot argument, for DEC, ARC, or SGI" 317 printf(
" (default arg for DEC is -a, for ARC/SGI -aN)\n");
318 printf(
" -p pc add a breakpoint (remember to use the '0x' " 319 "prefix for hex!)\n");
320 printf(
" -Q no built-in PROM emulation (use this for " 321 "running ROM images)\n");
322 printf(
" -R use random bootstrap cpu, instead of nr 0\n");
323 printf(
" -r register dumps before every instruction\n");
324 printf(
" -S initialize emulated RAM to random bytes, " 325 "instead of zeroes\n");
326 printf(
" -s f:name write statistics to file 'name', " 327 "f is one or more of the following:\n");
328 printf(
" v virtual program counter\n");
329 printf(
" p physical equivalent of program counter\n");
330 printf(
" i internal ic->f representation of " 331 "the program counter\n");
332 printf(
" and optionally:\n");
333 printf(
" d disable statistics gathering at " 335 printf(
" o overwrite instead of append\n");
336 printf(
" -T halt on non-existant memory accesses\n");
337 printf(
" -t show function trace tree\n");
338 printf(
" -U enable slow_serial_interrupts_hack_for_linux\n");
340 printf(
" -X use X11\n");
341 printf(
" -x open up new xterms for emulated serial ports " 342 "(default is on when\n using configuration files or" 343 " when X11 is used, off otherwise)\n");
344 printf(
" -Y n scale down framebuffer windows by n x n times\n");
346 printf(
" -Z n set nr of graphics cards, for emulating a " 347 "dual-head or tripple-head\n" 348 " environment (only for DECstation emulation)\n");
349 printf(
" -z disp add disp as an X11 display to use for " 352 printf(
"\nGeneral options:\n");
353 printf(
" -c cmd add cmd as a command to run before starting " 355 printf(
" -D skip the srandom call at startup\n");
356 printf(
" -H display a list of possible CPU and " 358 printf(
" -h display this help message\n");
359 printf(
" -k n set dyntrans translation caches to n MB (default" 361 printf(
" -K force the debugger to be entered at the end " 362 "of a simulation\n");
363 printf(
" -q quiet mode (don't print startup messages)\n");
364 printf(
" -V start up in the single-step debugger, paused\n");
365 printf(
" -v increase debug message verbosity\n");
367 printf(
"If you are selecting a machine type to emulate directly " 368 "on the command line,\nthen you must specify one or more names" 369 " of files that you wish to load into\n" 370 "memory. Supported formats are: ELF a.out ecoff srec syms raw\n" 371 "where syms is the text produced by running 'nm' (or 'nm -S') " 373 "To load a raw binary into memory, add \"address:\" in front " 375 "or \"address:skiplen:\" or \"address:skiplen:initialpc:\".\n" 377 " 0xbfc00000:rom.bin for a raw ROM image\n" 378 " 0xbfc00000:0x100:rom.bin for an image with " 379 "0x100 bytes header\n" 380 " 0xbfc00000:0x100:0xbfc00884:rom.bin " 381 "start with pc=0xbfc00884\n\n");
391 char ***diskimagesp,
int *n_diskimagesp)
393 int ch, res, using_switch_d = 0, using_switch_Z = 0;
394 int using_switch_e = 0, using_switch_E = 0;
395 bool using_switch_B =
false;
396 char *type = NULL, *subtype = NULL;
402 "BC:c:Dd:E:e:HhI:iJj:k:KM:Nn:Oo:p:QqRrSs:TtUVvW:" 408 while ((ch = getopt(argc, argv, opts)) != -1) {
411 using_switch_B =
true;
423 n_debugger_cmds-1] = strdup(
optarg));
426 skip_srandom_call = 1;
432 realloc(*diskimagesp,
433 sizeof(
char *) * (*n_diskimagesp)) );
440 if (using_switch_E ++ > 0) {
441 fprintf(stderr,
"-E already used.\n");
448 if (using_switch_e ++ > 0) {
449 fprintf(stderr,
"-e already used.\n");
457 printf(
"--------------------------------------------------------------------------\n\n");
458 printf(
"The following applies to the LEGACY modes only:\n\n");
484 fprintf(stderr,
"The dyntrans cache size must" 485 " be at least 1 MB.\n");
576 fprintf(stderr,
"Invalid scaledown value.\n");
596 fprintf(stderr,
"Run %s -h for help on command " 612 if (type == NULL && subtype == NULL &&
641 if (type != NULL || subtype != NULL) {
645 subtype = strdup(
"");
648 if (subtype[0] !=
'\0') {
689 fprintf(stderr,
"Machine specific options used directly on " 690 "the command line, but no machine\nemulation specified?\n");
698 fprintf(stderr,
"Implicitly %sturning on -v, because" 699 " of -i\n",
quiet_mode?
"turning off -q and " :
"");
705 fprintf(stderr,
"Implicitly %sturning on -v, because" 706 " of -r\n",
quiet_mode?
"turning off -q and " :
"");
720 if (using_switch_d) {
724 fprintf(stderr,
"\nNo filename given. Aborting.\n");
739 s2 = strrchr(s,
'/');
749 fprintf(stderr,
"Bad number of gfx cards (-Z).\n");
770 int main(
int argc,
char *argv[])
773 int constant_yes = 1;
774 int constant_true = 1;
776 int constant_false = 0;
781 char **diskimages = NULL;
782 int n_diskimages = 0;
811 settings_add(global_settings,
"force_debugger_at_exit", 1,
831 get_cmd_args(argc, argv, emul, &diskimages, &n_diskimages);
833 if (!skip_srandom_call) {
835 gettimeofday(&tv, NULL);
836 srandom(tv.tv_sec ^ getpid() ^ tv.tv_usec);
841 "Read the source code and/or documentation for other Copyright " 846 for (i=0; i<n_diskimages; i++)
850 for (i=1; i<argc; i++)
851 if (argv[i][0] ==
'@') {
852 fprintf(stderr,
"You can either start one " 853 "emulation with one machine directly from " 854 "the command\nline, or start one or more " 855 "emulations using configuration files." 865 for (i=1; i<argc; i++) {
866 if (argv[i][0] ==
'@') {
867 char *s = argv[i] + 1;
870 fprintf(stderr,
"More than one configuration " 871 "file cannot be used.\n");
875 if (
strlen(s) == 0 && i+1 < argc && *argv[i+1] !=
'@')
899 fprintf(stderr,
"No emulations defined. Maybe you forgot to " 900 "use -E xx and/or -e yy, to specify\nthe machine type." 901 " For example:\n\n %s -e 3max -d disk.img\n\n" 902 "to boot an emulated DECstation 5000/200 with a disk " 908 printf(
"No machine type specified? Run gxemul -H for a list\n" 909 "of available machine types. Use the -e or -E option(s)\n" 910 "to specify the machine type.\n");
void SetRunState(RunState newState)
Sets the RunState.
#define SETTINGS_FORMAT_YESNO
struct settings * settings_new(void)
size_t dyntrans_cache_size
void device_set_exit_on_error(int exit_on_error)
void debug(const char *fmt,...)
int slow_serial_interrupts_hack_for_linux
int force_debugger_at_exit
int console_warn_if_slaves_are_needed(int init)
static void ListTemplates()
Dump a list to stdout with all available machine templates.
void debug_indentation(int diff)
struct settings * settings
void SetSnapshottingEnabled(bool enabled)
Sets whether or not to use snapshots.
char * boot_string_argument
#define CHECK_ALLOCATION(ptr)
char * boot_kernel_filename
void internal_w(char *arg)
void console_slave(const char *arg)
struct machine * emul_add_machine(struct emul *e, char *name)
void settings_remove(struct settings *settings, const char *name)
void settings_destroy(struct settings *settings)
void fatal(const char *fmt,...)
#define ENTER_SINGLE_STEPPING
void console_allow_slaves(int allow)
static int RunTests()
Runs all unit tests in GXemul.
int machine_name_to_type(char *stype, char *ssubtype, int *type, int *subtype, int *arch)
static void DumpMachineAsHTML(const string &machineName)
struct emul * emul_create_from_configfile(char *fname)
static void UnregisterAllComponentClasses()
Unregisters all manually registered component classes.
int main(int argc, char *argv[])
void machine_list_available_types_and_cpus(void)
int halt_on_nonexistant_memaccess
#define SETTINGS_TYPE_SUBSETTINGS
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
void console_deinit(void)
#define DEFAULT_DYNTRANS_CACHE_SIZE
void emul_simple_init(struct emul *emul)
#define SETTINGS_FORMAT_BOOL
void settings_remove_all(struct settings *settings)
void settings_add(struct settings *settings, const char *name, int writable, int type, int format, void *ptr)
void machine_add_breakpoint_string(struct machine *machine, char *str)
struct machine ** machines
int allow_instruction_combinations
void InitUI()
Initializes the UI.
bool IsTemplateMachine(const string &templateName) const
#define SETTINGS_TYPE_INT
void machine_statistics_init(struct machine *, char *fname)
int Run()
Runs GXemul's main loop.
static void GenerateHTMLListOfComponents(bool machines)
int diskimage_add(struct machine *machine, char *fname)
struct settings * global_settings
void SetQuietMode(bool quietMode)
Sets whether or not to run in quiet mode.
struct emul * emul_new(char *name)
int show_nr_of_instructions
void emul_run(struct emul *emul)
void emul_destroy(struct emul *emul)
int use_random_bootstrap_cpu
bool ParseFilenames(string templateMachine, int filenameCount, char *filenames[])
Parses command line arguments (file names).
int get_cmd_args(int argc, char *argv[], struct emul *emul, char ***diskimagesp, int *n_diskimagesp)