--- trunk/man/gxemul.1 2007/10/08 16:19:23 20 +++ trunk/man/gxemul.1 2007/10/08 16:19:56 24 @@ -1,6 +1,6 @@ -.\" $Id: gxemul.1,v 1.39 2005/11/23 22:03:25 debug Exp $ +.\" $Id: gxemul.1,v 1.65 2006/06/22 13:22:40 debug Exp $ .\" -.\" Copyright (C) 2004-2005 Anders Gavare. All rights reserved. +.\" Copyright (C) 2004-2006 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: @@ -29,7 +29,7 @@ .\" This is a minimal man page for GXemul. Process this file with .\" groff -man -Tascii gxemul.1 or nroff -man gxemul.1 .\" -.Dd NOVEMBER 2005 +.Dd JUNE 2006 .Dt GXEMUL 1 .Os .Sh NAME @@ -42,9 +42,10 @@ .Nm .Op general options .Ar @configfile -.Nm -.Op userland, other, and general options -.Ar file Op Ar args ... +.\" TODO: Reenable this once userland emulation works: +.\" .Nm +.\" .Op userland, other, and general options +.\" .Ar file Op Ar args ... .Sh DESCRIPTION .Nm is an experimental instruction-level machine emulator. Several @@ -53,30 +54,24 @@ systems (e.g. NetBSD) run inside the emulator as if they were running on a real machine. .Pp -The processor architecture best emulated by GXemul is MIPS, but other -architectures (ARM and PowerPC) are also partially emulated. -.Pp -MIPS processors are emulated either using a simple type of binary -translator (on Alpha and i386 hosts), or using traditional slow -interpretation (all other hosts, including amd64 machines running in -64-bit mode). -.Pp -Non-MIPS processors are emulated using a newer dynamic -translation system (called dyntrans in the rest of this man page); -dyntrans does not require any host-specific code, so it should work on any -platform. Performance is somewhere between binary translation and -traditional interpretation. +Processors (ARM, MIPS, PowerPC) are emulated using a kind of dynamic +translation system. Performance is somewhere between traditional +interpretation and recompilation into native code. However, the dynamic +translation system used in GXemul does not (currently) generate native +code, and thus does not require platform-specific back-ends. In plain +English, this means that the dyntrans system works on any host architecture. .Pp -There are three ways to invoke the emulator: +The emulator can be invoked in the following ways: .Pp 1. When emulating a complete machine, configuration options can be entered directly on the command line. .Pp 2. Options can be read from a configuration file. -.Pp -3. When emulating a userland environment (syscall-only emulation, not -emulating complete machines), then the program name and its argument -should be given on the command line. (This mode doesn't really work yet.) +.\" .Pp +.\" 3. When emulating a userland environment (syscall-only emulation, not +.\" emulating complete machines), then the program name and its argument +.\" should be given on the command line. (This mode doesn't really work yet, +.\" and is disabled for stable release builds.) .Pp The easiest way to use the emulator is to supply settings directly on the command line. The most important thing you need to supply is the @@ -130,17 +125,19 @@ .Pp Other options: .Bl -tag -width Ds -.It Fl A -Disable load/store alignment checks in some cases. This might give a small -increase in performance, but the emulator will not run correctly if the -emulated code actually tries to do unaligned loads or stores. (This option -is only meaningful when emulating MIPS CPUs, when the host architecture is -Alpha or i386, and binary translation is enabled.) -.It Fl B -Disable dynamic binary translation. By default, bintrans -will be turned on if the host+target architecture combination is -supported. Currently, the only supported target architecture for bintrans -is MIPS, and the supported host architectures are Alpha and i386. +.\" The -A command line option is DEPRECATED and will be removed soon. +.\" .It Fl A +.\" Disable load/store alignment checks in some cases. This might give a small +.\" increase in performance, but the emulator will not run correctly if the +.\" emulated code actually tries to do unaligned loads or stores. (This option +.\" is only meaningful when emulating MIPS CPUs, when the host architecture is +.\" Alpha or i386, and binary translation is enabled.) +.\" .It Fl B +.\" Disable native translation backends. By default, translation backends are +.\" used if the host+target architecture combination is supported. Currently, +.\" the only supported host architecture for the old bintrans system (used +.\" when emulating MIPS processors) are Alpha and i386. The old bintrans +.\" system will hopefully be removed some day. .It Fl C Ar x Try to emulate a specific CPU type, .Ar "x". @@ -148,12 +145,12 @@ (Use .Fl H to get a list of available CPU types.) -.It Fl d Ar name +.It Fl d Ar [modifiers:]filename Add -.Ar name +.Ar filename as a disk image. By adding one or more modifier characters and then a colon (":") as a prefix to -.Ar "name", +.Ar filename, you can modify the way the disk image is treated. Available modifiers are: .Bl -tag -width Ds .It b @@ -168,17 +165,30 @@ Override the default geometry; use H heads and S sectors-per-track. (The number of cylinders is calculated automatically.) .It i -IDE. +IDE. (This is the default for most machine types.) .It r Read-only (don't allow changes to be written to the file). .It s -SCSI (this is the default for most machine types). +SCSI. .It t Tape. .It 0-7 Force a specific ID number. .El .Pp +For SCSI devices, the ID number is the SCSI ID. For IDE harddisks, the ID +number has the following meaning: +.Bl -tag -width Ds +.It 0 +Primary master. +.It 1 +Primary slave. +.It 2 +Secondary master. +.It 3 +Secondary slave. +.El +.Pp Unless otherwise specified, filenames ending with ".iso" or ".cdr" are assumed to be CDROM images. Most others are assumed to be disks. Depending on which machine is being emulated, the default for disks can be either @@ -190,6 +200,11 @@ heads and cylinders are assumed to be 2 and 80, respectively, and the number of sectors per track is calculated automatically. (This works for 720KB, 1.2MB, 1.44MB, and 2.88MB floppies.) +.It Fl G Ar port +Pause at startup, and listen to TCP port +.Ar port +for incoming remote GDB connections. The emulator starts up in paused +mode, and it is up to the remote GDB instance to start the session. .It Fl I Ar x Emulate clock interrupts at .Ar x @@ -199,29 +214,36 @@ .It Fl i Display each instruction as it is being executed. .It Fl J -Disable some speed tricks. For MIPS emulation, these are mostly -timing-related. For non-MIPS emulation (i.e. those modes using dyntrans), -this flag disables the use of "instruction combinations". +Disable some speed tricks. This usually means disabling the use of +dyntrans "instruction combinations". .It Fl j Ar n Set the name of the kernel to .Ar "n". When booting from an ISO9660 filesystem, the emulator will try to boot using this file. (In some emulation modes, eg. DECstation, this name is passed along to the boot program. Useful names are "bsd" for OpenBSD/pmax, -or "vmunix" for Ultrix.) +"vmunix" for Ultrix, or "vmsprite" for Sprite.) .It Fl M Ar m Emulate .Ar m MBs of physical RAM. This overrides the default amount of RAM for the selected machine type. -.It Fl m Ar nr -Run at most -.Ar nr -instructions (on any cpu). .It Fl N -Display nr of instructions/second average, at regular intervals. +Display the number of executed instructions per second on average, at +regular intervals. .It Fl n Ar nr -Set nr of CPUs (for SMP experiments). +Set the number of processors in the machine, for SMP experiments. +.Pp +Note: The emulator allocates quite a +lot of virtual memory for per-CPU translation tables. On 64-bit hosts, +this is normally not a problem. On 32-bit hosts, this can use up all +available virtual userspace memory. The solution is to either run the +emulator on a 64-bit host, or limit the number of emulated CPUs to a +reasonable number (say, less than 32). +.Pp +Note 2: SMP simulation is not working very well yet; multiple processors +are simulated, but synchronization between the processors does not map +very well to how real-world SMP systems work. .It Fl O Force a "netboot" (tftp instead of disk), even when a disk image is present (for DECstation, SGI, and ARC emulation). @@ -231,28 +253,39 @@ .Ar arg for DEC is "-a", for ARC/SGI it is "-aN", and for CATS it is "-A". .It Fl p Ar pc -Add a breakpoint. (Remember to use the "0x" prefix for hex.) +Add a breakpoint. +.Ar pc +can be a symbol, or a numeric value. (Remember to use the "0x" prefix for +hexadecimal values.) .It Fl Q -Disable the built-in PROM emulation. This is useful for running raw ROM -images from real machines. +Disable the built-in PROM emulation. This is useful for +experimenting with running raw ROM images from real machines. .It Fl R Use a random bootstrap cpu, instead of CPU nr 0. (For SMP experiments.) .It Fl r Dump register contents for every executed instruction. .It Fl S -Initialize the emulated RAM to random data, instead of zeroes. -.It Fl T -Enter the single-step debugger on unimplemented memory accesses. +Initialize emulated RAM to random data, instead of zeroes. This option +is useful when trying to trigger bugs in a program that occur because the +program assumed that uninitialized memory contains zeros. (Use with +care.) .It Fl t Show a trace tree of all function calls being made. .It Fl U Enable slow_serial_interrupts_hack_for_linux. .It Fl X -Use X11. +Use X11. This option enables graphical framebuffers. .It Fl x -Open up new xterms for emulated serial ports. (Default is to open up -xterms when using configuration files, but not when starting an -emulation with settings directly on the command line.) +Open up new xterms for emulated serial ports. The default behaviour is to +open up xterms when using configuration files, or if X11 is enabled. When +starting up a simple emulation session with settings directly on the +command line, and neither +.Fl X +nor +.Fl x +is used, then all output is confined to the terminal that +.Nm +started in. .It Fl Y Ar n Scale down framebuffer windows by .Ar n @@ -269,10 +302,6 @@ .Ar -2 with VGA text mode emulation will result in 80x25 character cells rendered in a 1280x800 window, instead of the normal resolution of 640x400. -.It Fl y Ar x -Set max_random_cycles_per_chunk to -.Ar x -(experimental). .It Fl Z Ar n Set the number of graphics cards, for emulating a dual-head or tripple-head environment. (Only for DECstation emulation so far.) @@ -282,18 +311,25 @@ as an X11 display to use for framebuffers. .El .Pp -Userland options: -.Bl -tag -width Ds -.It Fl u Ar emul-mode -Userland-only (syscall) emulation. (Use -.Fl H -to get a list of available emulation modes.) Some (but not all) of the -options listed under Other options above can also be used with userland -emulation. -.El -.Pp +.\" Userland options: +.\" .Bl -tag -width Ds +.\" .It Fl u Ar emul-mode +.\" Userland-only (syscall) emulation. (Use +.\" .Fl H +.\" to get a list of available emulation modes.) Some (but not all) of the +.\" options listed under Other options above can also be used with +.\" userland emulation. +.\" .El +.\" .Pp General options: .Bl -tag -width Ds +.It Fl c Ar cmd +Add +.Ar cmd +as a command to run before starting the simulation. A similar effect can +be achieved by using the +.Fl V +option, and entering the commands manually. .It Fl D Guarantee fully deterministic behavior. Normally, the emulator calls srandom() with a seed based on the current time at startup. When the @@ -309,21 +345,24 @@ emulation modes. (Most of these don't work. Please read the documentation included in the .Nm -distribution for details on which modes that actually work.) +distribution for details on which modes that actually work. Userland +emulation is not included in stable release builds, since it doesn't work +yet.) .It Fl h Display a list of all available command line options. .It Fl K Force the single-step debugger to be entered at the end of a simulation. .It Fl q Quiet mode; this suppresses startup messages. -.It Fl s -For MIPS emulation: Show opcode usage statistics after the simulation. -For non-MIPS emulation (i.e. using dyntrans): Save statistics to a file at -regular intervals of which physical addresses that were executed. +.\".It Fl s +.\"For MIPS emulation: Show opcode usage statistics after the simulation. +.\"For non-MIPS emulation (i.e. using dyntrans): Save statistics to a file +.\"at regular intervals of which physical addresses that were executed. .It Fl V Start up in the single-step debugger, paused. .It Fl v -Verbose debug messages. +Increase verbosity (show more debug messages). This option can be used +multiple times. .El .Pp Configuration file startup: @@ -359,34 +398,51 @@ .Pp .Dl "gxemul -E testmips -V hello_mips" .Pp -(Paused mode means that you enter the interactive single-step debugger -directly at startup, instead of launching the Hello World program.) +Paused mode means that you enter the interactive single-step debugger +directly at startup, instead of launching the Hello World program. +.Pp +The paused mode is also what should be used when running "unknown" files +for the first time in the emulator. E.g. if you have a binary which you +think is some kind of MIPS ROM image, then you can try the following: +.Pp +.Dl "gxemul -vv -E baremips -V 0xbfc00000:image.raw" +.Pp +You can then use the single-stepping functionality of the built-in +debugger to run the code in the ROM image, to see how it behaves. Based on +that, you can deduce what machine type it was actually from (the +baremips machine is not a real machine), and perhaps try again with +another emulation mode. +.Pp +In general, however, real ROM images require much more emulation detail +than GXemul provides, so they can usually not run. .Pp Please read the documentation for more details. .Sh BUGS -There are many bugs. Some of the known bugs are listed in the BUGS +There are many bugs. Some of the known bugs are mentioned in the TODO file in the .Nm -source distribution, some are indirectly mentioned in the TODO file, -and some are mentioned in the source code itself. -.Pp -The binary translation subsystem is really terrible, but it is less -terrible than running without it. +source distribution, some are marked as TODO in the source code itself. .Pp Userland (syscall-only) emulation doesn't really work yet. .Pp -Emulation of MIPS CPUs is done differently from other emulation modes; the -documentation sometimes only reflects the way things work with MIPS -emulation, and it is incorrect when applied to e.g. ARM emulation. +The documentation sometimes only reflects the way things worked with +the old MIPS emulation mode (prior to 0.4.0), and it is incorrect when +applied to current releases. .Pp .Nm -does not simulate individual pipe-line stages or penalties caused by -branch-prediction misses or cache misses, so it cannot be used for -accurate simulation of any actual real-world processor. +is in general not cycle-accurate; it does not simulate individual +pipe-line stages or penalties caused by branch-prediction misses or +cache misses, so it cannot be used for accurate simulation of any actual +real-world processor. .Pp .Nm -is not timing-accurate. +is not timing-accurate, i.e. clocks inside the emulator are in general +not at all synched with clocks in the real world. There are a few +exceptions to this rule (the mc146818 device tries to automagically +adjust emulated timer ticks to actual emulation speed). .Sh AUTHOR -Anders Gavare +GXemul is Copyright (C) 2003-2006 Anders Gavare .Pp -See http://gavare.se/gxemul/ for more information. +See http://gavare.se/gxemul/ for more information. For other Copyright +messages, see the corresponding parts of the source code and/or +documentation.