main.cc Source File
Back to the index.
Go to the documentation of this file.
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 other Copyright messages.\n");
234 printf(
"\nUsage: %s [machine, other, and general options] [file [...]]\n",
progname);
235 printf(
" or %s [general options] @configfile\n",
progname);
238 printf(
"\nRun %s -h for help on command line options.\n",
progname);
242 printf(
"\nMachine selection options:\n");
243 printf(
" -E t try to emulate machine type t. (Use -H to get "
244 "a list of types.)\n");
245 printf(
" -e st try to emulate machine subtype st. (Use this "
248 printf(
"\nOther options:\n");
249 printf(
" -C x try to emulate a specific CPU. (Use -H to get a "
250 "list of types.)\n");
251 printf(
" -d fname add fname as a disk image. You can add \"xxx:\""
253 printf(
" where xxx is one or more of the following:\n");
254 printf(
" b specifies that this is the boot"
256 printf(
" c CD-ROM\n");
258 printf(
" f FLOPPY\n");
259 printf(
" gH;S; set geometry to H heads and S"
260 " sectors-per-track\n");
262 printf(
" oOFS; set base offset to OFS (for ISO9660"
264 printf(
" r read-only (don't allow changes to the"
268 printf(
" V add an overlay\n");
269 printf(
" 0-7 force a specific ID\n");
270 printf(
" -I hz set the main cpu frequency to hz (not used by "
271 "all combinations\n of machines and guest OSes)\n");
272 printf(
" -i display each instruction as it is executed\n");
273 printf(
" -J disable dyntrans instruction combinations\n");
274 printf(
" -j name set the name of the kernel; for DECstation "
275 "emulation, this passes\n the name to the bootloader,"
277 printf(
" -j netbsd (NetBSD/pmax) "
278 "-j bsd (OpenBSD/pmax)\n");
279 printf(
" -j vmsprite (Sprite/pmax) "
280 "-j vmunix (Ultrix/RISC)\n");
281 printf(
" For other emulation modes, if the boot disk is an"
282 " ISO9660\n filesystem, -j sets the name of the"
283 " kernel to load.\n");
284 printf(
" -M m emulate m MBs of physical RAM\n");
285 printf(
" -N display nr of instructions/second average, at"
286 " regular intervals\n");
287 printf(
" -n nr set nr of CPUs (for SMP experiments)\n");
288 printf(
" -O force netboot (tftp instead of disk), even when"
290 " present (for DECstation, SGI, and ARC emulation)\n");
291 printf(
" -o arg set the boot argument, for DEC, ARC, or SGI"
293 printf(
" (default arg for DEC is -a, for ARC/SGI -aN)\n");
294 printf(
" -p pc add a breakpoint (remember to use the '0x' "
295 "prefix for hex!)\n");
296 printf(
" -Q no built-in PROM emulation (use this for "
297 "running ROM images)\n");
298 printf(
" -R use random bootstrap cpu, instead of nr 0\n");
299 printf(
" -r register dumps before every instruction\n");
300 printf(
" -S initialize emulated RAM to random bytes, "
301 "instead of zeroes\n");
302 printf(
" -s f:name write statistics to file 'name', "
303 "f is one or more of the following:\n");
304 printf(
" v virtual program counter\n");
305 printf(
" p physical equivalent of program counter\n");
306 printf(
" i internal ic->f representation of "
307 "the program counter\n");
308 printf(
" and optionally:\n");
309 printf(
" d disable statistics gathering at "
311 printf(
" o overwrite instead of append\n");
312 printf(
" -T halt on non-existant memory accesses\n");
313 printf(
" -t show function trace tree\n");
314 printf(
" -U enable slow_serial_interrupts_hack_for_linux\n");
316 printf(
" -X use X11\n");
317 printf(
" -x open up new xterms for emulated serial ports "
318 "(default is on when\n using configuration files or"
319 " when X11 is used, off otherwise)\n");
320 printf(
" -Y n scale down framebuffer windows by n x n times\n");
322 printf(
" -Z n set nr of graphics cards, for emulating a "
323 "dual-head or tripple-head\n"
324 " environment (only for DECstation emulation)\n");
325 printf(
" -z disp add disp as an X11 display to use for "
328 printf(
"\nGeneral options:\n");
329 printf(
" -c cmd add cmd as a command to run before starting "
331 printf(
" -D skip the srandom call at startup\n");
332 printf(
" -H display a list of possible CPU and "
334 printf(
" -h display this help message\n");
335 printf(
" -k n set dyntrans translation caches to n MB (default"
337 printf(
" -K force the debugger to be entered at the end "
338 "of a simulation\n");
339 printf(
" -q quiet mode (don't print startup messages)\n");
340 printf(
" -V start up in the single-step debugger, paused\n");
341 printf(
" -v increase debug message verbosity\n");
343 printf(
"If you are selecting a machine type to emulate directly "
344 "on the command line,\nthen you must specify one or more names"
345 " of files that you wish to load into\n"
346 "memory. Supported formats are: ELF a.out ecoff srec syms raw\n"
347 "where syms is the text produced by running 'nm' (or 'nm -S') "
349 "To load a raw binary into memory, add \"address:\" in front "
351 "or \"address:skiplen:\" or \"address:skiplen:initialpc:\".\n"
353 " 0xbfc00000:rom.bin for a raw ROM image\n"
354 " 0xbfc00000:0x100:rom.bin for an image with "
355 "0x100 bytes header\n"
356 " 0xbfc00000:0x100:0xbfc00884:rom.bin "
357 "start with pc=0xbfc00884\n\n");
359 printf(
"\n\"New framework\" options (experimental):\n");
360 printf(
"\nUsage: %s [options] -e name [additional components and files [...]]\n",
progname);
361 printf(
" or %s [options] configfile\n",
progname);
365 printf(
" -B Enable snapshotting (reverse stepping support).\n");
366 printf(
" -H Display a list of available machine templates.\n");
367 printf(
" -e name Start with a machine based on template 'name'.\n");
368 printf(
" -q Quiet mode (suppress debug messages).\n");
369 printf(
" -V Start up in interactive debugging mode, paused.\n");
380 char ***diskimagesp,
int *n_diskimagesp)
382 int ch, res, using_switch_d = 0, using_switch_Z = 0;
383 int using_switch_e = 0, using_switch_E = 0;
384 bool using_switch_B =
false;
385 char *type = NULL, *subtype = NULL;
391 "BC:c:Dd:E:e:HhI:iJj:k:KM:Nn:Oo:p:QqRrSs:TtUVvW:"
397 while ((ch = getopt(argc, argv, opts)) != -1) {
400 using_switch_B =
true;
412 n_debugger_cmds-1] = strdup(
optarg));
415 skip_srandom_call = 1;
421 realloc(*diskimagesp,
422 sizeof(
char *) * (*n_diskimagesp)) );
429 if (using_switch_E ++ > 0) {
430 fprintf(stderr,
"-E already used.\n");
437 if (using_switch_e ++ > 0) {
438 fprintf(stderr,
"-e already used.\n");
446 printf(
"--------------------------------------------------------------------------\n\n");
447 printf(
"The following applies to the LEGACY modes only:\n\n");
473 fprintf(stderr,
"The dyntrans cache size must"
474 " be at least 1 MB.\n");
565 fprintf(stderr,
"Invalid scaledown value.\n");
585 fprintf(stderr,
"Run %s -h for help on command "
601 if (type == NULL && subtype == NULL &&
630 if (type != NULL || subtype != NULL) {
634 subtype = strdup(
"");
637 if (subtype[0] !=
'\0') {
678 fprintf(stderr,
"Machine specific options used directly on "
679 "the command line, but no machine\nemulation specified?\n");
687 fprintf(stderr,
"Implicitly %sturning on -v, because"
688 " of -i\n",
quiet_mode?
"turning off -q and " :
"");
694 fprintf(stderr,
"Implicitly %sturning on -v, because"
695 " of -r\n",
quiet_mode?
"turning off -q and " :
"");
709 if (using_switch_d) {
713 fprintf(stderr,
"\nNo filename given. Aborting.\n");
728 s2 = strrchr(s,
'/');
738 fprintf(stderr,
"Bad number of gfx cards (-Z).\n");
759 int main(
int argc,
char *argv[])
762 int constant_yes = 1;
763 int constant_true = 1;
765 int constant_false = 0;
770 char **diskimages = NULL;
771 int n_diskimages = 0;
822 if (!skip_srandom_call) {
824 gettimeofday(&tv, NULL);
825 srandom(tv.tv_sec ^ getpid() ^ tv.tv_usec);
830 "Read the source code and/or documentation for other Copyright "
835 for (i=0; i<n_diskimages; i++)
839 for (i=1; i<argc; i++)
840 if (argv[i][0] ==
'@') {
841 fprintf(stderr,
"You can either start one "
842 "emulation with one machine directly from "
843 "the command\nline, or start one or more "
844 "emulations using configuration files."
854 for (i=1; i<argc; i++) {
855 if (argv[i][0] ==
'@') {
856 char *s = argv[i] + 1;
859 fprintf(stderr,
"More than one configuration "
860 "file cannot be used.\n");
864 if (
strlen(s) == 0 && i+1 < argc && *argv[i+1] !=
'@')
888 fprintf(stderr,
"No emulations defined. Maybe you forgot to "
889 "use -E xx and/or -e yy, to specify\nthe machine type."
890 " For example:\n\n %s -e 3max -d disk.img\n\n"
891 "to boot an emulated DECstation 5000/200 with a disk "
897 printf(
"No machine type specified? Run gxemul -H for a list\n"
898 "of available machine types. Use the -e or -E option(s)\n"
899 "to specify the machine type.\n");
int force_debugger_at_exit
int console_warn_if_slaves_are_needed(int init)
void SetSnapshottingEnabled(bool enabled)
Sets whether or not to use snapshots.
void debug(const char *fmt,...)
struct settings * settings
bool ParseFilenames(string templateMachine, int filenameCount, char *filenames[])
Parses command line arguments (file names).
void settings_remove(struct settings *settings, const char *name)
void internal_w(char *arg)
int show_nr_of_instructions
void settings_add(struct settings *settings, const char *name, int writable, int type, int format, void *ptr)
void machine_list_available_types_and_cpus(void)
void device_set_exit_on_error(int exit_on_error)
void emul_simple_init(struct emul *emul)
int use_random_bootstrap_cpu
int allow_instruction_combinations
int Run()
Runs GXemul's main loop.
struct emul * emul_new(char *name)
void InitUI()
Initializes the UI.
char * boot_string_argument
void emul_run(struct emul *emul)
bool IsTemplateMachine(const string &templateName) const
void machine_add_breakpoint_string(struct machine *machine, char *str)
int slow_serial_interrupts_hack_for_linux
void console_allow_slaves(int allow)
static void UnregisterAllComponentClasses()
Unregisters all manually registered component classes.
#define ENTER_SINGLE_STEPPING
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
void SetRunState(RunState newState)
Sets the RunState.
void settings_remove_all(struct settings *settings)
size_t dyntrans_cache_size
int halt_on_nonexistant_memaccess
struct machine * emul_add_machine(struct emul *e, char *name)
int main(int argc, char *argv[])
void console_slave(const char *arg)
void fatal(const char *fmt,...)
int diskimage_add(struct machine *machine, char *fname)
struct settings * global_settings
int get_cmd_args(int argc, char *argv[], struct emul *emul, char ***diskimagesp, int *n_diskimagesp)
#define SETTINGS_TYPE_SUBSETTINGS
uint32_t physical_ram_in_mb
char * boot_kernel_filename
static void ListTemplates()
Dump a list to stdout with all available machine templates.
void settings_destroy(struct settings *settings)
void SetQuietMode(bool quietMode)
Sets whether or not to run in quiet mode.
static void GenerateHTMLListOfComponents(bool machines)
#define SETTINGS_FORMAT_BOOL
#define DEFAULT_DYNTRANS_CACHE_SIZE
void emul_destroy(struct emul *emul)
void debug_indentation(int diff)
struct emul * emul_create_from_configfile(char *fname)
static void DumpMachineAsHTML(const string &machineName)
struct machine ** machines
struct settings * settings_new(void)
void console_deinit(void)
void machine_statistics_init(struct machine *, char *fname)
int machine_name_to_type(char *stype, char *ssubtype, int *type, int *subtype, int *arch)
#define SETTINGS_FORMAT_YESNO
#define SETTINGS_TYPE_INT
static int RunTests()
Runs all unit tests in GXemul.
#define CHECK_ALLOCATION(ptr)
Generated on Tue Aug 25 2020 19:25:06 for GXemul by
1.8.18