1GXEMUL(1)                 BSD General Commands Manual                GXEMUL(1)
2

NAME

4     gxemul — an experimental framework for full-system machine emulation
5

SYNOPSIS

7     gxemul [machine, other, and general options] [file ...]
8     gxemul [general options] @configfile
9     gxemul [userland, other, and general options] file [args ...]
10

DESCRIPTION

12     gxemul is a framework for full-system computer architecture emulation.
13     Several processor architectures and machine types have been implemented.
14     It is working well enough to allow unmodified "guest" operating systems
15     (e.g. NetBSD) to run inside the emulator, as if they were running on real
16     hardware.
17
18     The emulator emulates (networks of) real machines. The machines may con‐
19     sist of ARM, MIPS, Motorola 88K, PowerPC, and SuperH processors, and var‐
20     ious surrounding hardware components such as framebuffers, busses, inter‐
21     rupt controllers, ethernet controllers, disk controllers, and serial port
22     controllers.
23
24     The emulator can be invoked in the following ways:
25
26     1. When emulating a complete machine, configuration options can be sup‐
27     plied directly on the command line.
28
29     2. Options can be read from a configuration file.
30
31     3. When emulating a userland environment (syscall-only emulation, not
32     emulating complete machines), then the program name and its argument
33     should be given on the command line. (This mode is not really usable
34     yet.)
35
36     The easiest way to use the emulator is to supply settings directly on the
37     command line.
38
39     The most important thing you need to supply is the file argument. This is
40     the name of a binary file (an ELF, a.out, COFF/ECOFF, SREC, or a raw
41     binary image) which you wish to run in the emulator. This file might be
42     an operating system kernel, or perhaps a ROM image file.  If more than
43     one filename is supplied, all files are loaded into memory, and the entry
44     point (if available) is taken from the last file.
45
46     Apart from the name of a binary file, you must also use the -E and/or -e
47     options to select which emulation mode to use. This is necessary because
48     the emulator cannot in general deduce this from the file being executed.
49     For example, a MIPS-based machine from DEC (a DECstation) is very differ‐
50     ent from a MIPS-based machine from SGI. Use gxemul -H to get a list of
51     available emulation modes.
52
53     There are three exceptions to the normal invocation usage mentioned
54     above.
55
56     1. For DECstation emulation, if you have a bootable DECstation harddisk
57     or CDROM image, then just supplying the diskimage via the -d option is
58     sufficient. The filename of the kernel can then be skipped, as the emula‐
59     tor runs the bootblocks from the diskimage directly and doesn't need the
60     kernel as a separate file.
61
62     2. If you supply an ISO9660 CDROM disk image, then using the -j option to
63     indicate a file on the CDROM filesystem to load is sufficient; no addi‐
64     tional kernel filename needs to be supplied on the command line.
65
66     3. For Dreamcast emulation, when booting e.g. a NetBSD/dreamcast CDROM
67     image, it is enough to supply the disk image (with the correct ISO parti‐
68     tion start offset). Bootblocks will be read directly from the CDROM
69     image, and there is no need to supply the name of an external kernel on
70     the command line.
71
72     Gzipped kernels are automatically unzipped, by calling the external gun‐
73     zip program, both when specifying a gzipped file directly on the command
74     line and when loading such a file using the -j option.
75
76     Machine selection options:
77
78     -E t    Try to emulate machine type t.  This option is not always needed,
79             if the -e option uniquely selects a machine.  (Use -H to get a
80             list of types.)
81
82     -e st   Try to emulate machine subtype st.  Use this together with -E.
83             (This option is not always needed, if a machine type has no sub‐
84             types.)
85
86     Other options:
87
88     -C x    Try to emulate a specific CPU type, x.  This overrides the
89             default CPU type for the machine being emulated.  (Use -H to get
90             a list of available CPU types.)
91
92     -d [modifiers:]filename
93             Add filename as a disk image. By adding one or more modifier
94             characters and then a colon (":") as a prefix to filename, you
95             can modify the way the disk image is treated. Available modifiers
96             are:
97
98             b       Specifies that this is a boot device.
99
100             c       CD-ROM.
101
102             d       DISK (this is the default).
103
104             f       FLOPPY.
105
106             gH;S;   Override the default geometry; use H heads and S sectors-
107                     per-track.  (The number of cylinders is calculated auto‐
108                     matically.)
109
110             i       IDE. (This is the default for most machine types.)
111
112             oOFS;   Set the base offset for an ISO9660 filesystem on a disk
113                     image. The default is 0. A suitable offset when booting
114                     from Dreamcast ISO9660 filesystem images, which are off‐
115                     set by 11702 sectors, is 23965696.
116
117             r       Read-only (don't allow changes to be written to the
118                     file).
119
120             s       SCSI.
121
122             t       Tape.
123
124             V       Add an overlay filename to an already defined disk image.
125                     (A ID number must also be specified when this flag is
126                     used. See the documentation for an example of how to use
127                     overlays.)
128
129             0-7     Force a specific ID number.
130
131             For SCSI devices, the ID number is the SCSI ID. For IDE hard‐
132             disks, the ID number has the following meaning:
133
134             0       Primary master.
135
136             1       Primary slave.
137
138             2       Secondary master.
139
140             3       Secondary slave.
141
142             Unless otherwise specified, filenames ending with ".iso" or
143             ".cdr" are assumed to be CDROM images. Most others are assumed to
144             be disks. Depending on which machine is being emulated, the
145             default for disks can be either SCSI or IDE. Some disk images
146             that are very small are assumed to be floppy disks. (If you are
147             not happy with the way a disk image is detected, then you need to
148             use explicit prefixes to force a specific type.)
149
150             For floppies, the gH;S; prefix is ignored. Instead, the number of
151             heads and cylinders are assumed to be 2 and 80, respectively, and
152             the number of sectors per track is calculated automatically.
153             (This works for 720KB, 1.2MB, 1.44MB, and 2.88MB floppies.)
154
155     -I hz   Set the main CPU's frequency to hz Hz. This option does not work
156             for all emulated machine modes. It affects the way count/compare
157             interrupts are faked to simulate emulated time = real world time.
158             If the guest operating system relies on RTC interrupts instead of
159             count/compare interrupts, then this option has no effect.
160
161             Setting the frequency to zero disables automatic synchronization
162             of emulated time vs real world time, and the count/compare system
163             runs at a fixed rate.
164
165     -i      Enable instruction trace, i.e. display disassembly of each
166             instruction as it is being executed.
167
168     -J      Disable instruction combinations in the dynamic translator.
169
170     -j n    Set the name of the kernel to n.  When booting from an ISO9660
171             filesystem, the emulator will try to boot using this file. (In
172             some emulation modes, eg. DECstation, this name is passed along
173             to the boot program. Useful names are "bsd" for OpenBSD/pmax,
174             "vmunix" for Ultrix, or "vmsprite" for Sprite.)
175
176     -M m    Emulate m MBs of physical RAM. This overrides the default amount
177             of RAM for the selected machine type.
178
179     -N      Display the number of executed instructions per second on aver‐
180             age, at regular intervals.
181
182     -n nr   Set the number of processors in the machine, for SMP experiments.
183
184             Note 1: The emulator allocates quite a lot of virtual memory for
185             per-CPU translation tables. On 64-bit hosts, this is normally not
186             a problem. On 32-bit hosts, this can use up all available virtual
187             userspace memory. The solution is to either run the emulator on a
188             64-bit host, or limit the number of emulated CPUs to a reasonably
189             low number.
190
191             Note 2: SMP simulation is not working very well yet; multiple
192             processors are simulated, but synchronization between the proces‐
193             sors does not map very well to how real-world SMP systems work.
194
195     -O      Force a "netboot" (tftp instead of disk), even when a disk image
196             is present (for DECstation, SGI, and ARC emulation).
197
198     -o arg  Set the boot argument (mostly useful for DEC, ARC, or SGI emula‐
199             tion).  Default arg for DEC is "-a", for ARC/SGI it is "-aN", and
200             for CATS it is "-A".
201
202     -p pc   Add a breakpoint.  pc can be a symbol, or a numeric value.
203             (Remember to use the "0x" prefix for hexadecimal values.)
204
205     -Q      Disable the built-in (software-only) PROM emulation. This option
206             is useful for experimenting with running raw ROM images from real
207             machines. The default behaviour of the emulator is to "fake" cer‐
208             tain PROM calls used by guest operating systems (e.g. NetBSD), so
209             that no real PROM image is needed.
210
211     -R      Use a random bootstrap cpu, instead of CPU nr 0. (This option is
212             only meaningful together with the -n option.)
213
214     -r      Dump register contents for every executed instruction.
215
216     -S      Initialize emulated RAM to random data, instead of zeroes. This
217             option is useful when trying to trigger bugs in a program that
218             occur because the program assumed that uninitialized memory con‐
219             tains zeros. (Use with care.)
220
221     -s flags:filename
222             Gather statistics based on the current emulated program counter
223             value, while the program executes. The statistics is actually
224             just a raw dump of all program counter values in sequence, suit‐
225             able for post-analysis with separate tools. Output is appended to
226             filename.
227
228             The flags should include one or more of the following type speci‐
229             fiers:
230
231             v       Virtual. This means that the program counter value is
232                     used.
233
234             p       Physical. This means that the physical address of where
235                     the program is actually running is used.
236
237             i       Instruction call. This type of statistics gathering is
238                     practically only useful during development of the emula‐
239                     tor itself. The output is a list of addresses of instruc‐
240                     tion call functions (ic->f), which after some post-pro‐
241                     cessing can be used as a basis for deciding when to
242                     implement instruction combinations.
243
244             The flags may also include the following optional modifiers:
245
246             d       Disabled at startup.
247
248             o       Overwrite the file, instead of appending to it.
249
250             Statistics gathering can be enabled/disabled at runtime by using
251             the "statistics_enabled = yes" and "statistics_enabled = no"
252             debugger commands.
253
254             When gathering instruction statistics using the -s option,
255             instruction combinations are always disabled (i.e. an implicit -J
256             flag is added to the command line).
257
258     -T      Halt if the emulated program attempts to access non-existing mem‐
259             ory.
260
261     -t      Show a trace tree of all function calls being made.
262
263     -U      Enable slow_serial_interrupts_hack_for_linux.
264
265     -X      Use X11. This option enables graphical framebuffers.
266
267     -x      Open up new xterms for emulated serial ports. The default behav‐
268             iour is to open up xterms when using configuration files, or if
269             X11 is enabled. When starting up a simple emulation session with
270             settings directly on the command line, and neither -X nor -x is
271             used, then all output is confined to the terminal that gxemul
272             started in.
273
274     -Y n    Scale down framebuffer windows by n x n times. This option is
275             useful when emulating a very large framebuffer, and the actual
276             display is of lower resolution. If n is negative, then there will
277             be no scaledown, but emulation of certain graphic controllers
278             will be scaled up by -n times instead. E.g. Using -2 with VGA
279             text mode emulation will result in 80x25 character cells rendered
280             in a 1280x800 window, instead of the normal resolution of
281             640x400.
282
283     -Z n    Set the number of graphics cards, for emulating a dual-head or
284             tripple-head environment. (Only for DECstation emulation so far.)
285
286     -z disp
287             Add disp as an X11 display to use for framebuffers.
288
289     Userland options:
290
291     -u emul-mode
292             Userland-only (syscall) emulation. (Use -H to get a list of
293             available emulation modes.) Some (but not all) of the options
294             listed under Other options above can also be used with userland
295             emulation.
296
297             Note: Userland (syscall) emulation does not really work yet.
298
299     General options:
300
301     -c cmd  Add cmd as a command to run before starting the simulation. A
302             similar effect can be achieved by using the -V option, and enter‐
303             ing the commands manually.
304
305     -D      Causes the emulator to skip a call to srandom(). This leads to
306             somewhat more deterministic behaviour than running without this
307             option.  However, if the emulated machine has clocks or timer
308             interrupt sources, or if user interaction is taking place (e.g.
309             keyboard input at irregular intervals), then this option is mean‐
310             ingless.
311
312     -H      Display a list of available CPU types, machine types, and user‐
313             land emulation modes. (Most of these don't work. Please read the
314             documentation included in the gxemul distribution for details on
315             which modes that actually work. Userland emulation is not
316             included in stable release builds, since it doesn't work yet.)
317
318     -h      Display a list of all available command line options.
319
320     -k n    Set the size of the dyntrans cache (per emulated CPU) to n MB.
321             The default size is 48 MB.
322
323     -K      Force the single-step debugger to be entered at the end of a sim‐
324             ulation.
325
326     -q      Quiet mode; this suppresses startup messages.
327
328     -V      Start up in the single-step debugger, paused.
329
330     -v      Increase verbosity (show more debug messages). This option can be
331             used multiple times.
332
333     Configuration file startup:
334
335     @ configfile
336             Start an emulation based on the contents of configfile.
337
338     For more information, please read the documentation in the doc/ subdirec‐
339     tory of the gxemul distribution.
340

EXAMPLES

342     The following command will start NetBSD/pmax on an emulated DECstation
343     5000/200 (3MAX):
344
345           gxemul -e 3max -d nbsd_pmax.img
346
347     nbsd_pmax.img should be a raw disk image containing a bootable Net‐
348     BSD/pmax filesystem.
349
350     The following command will start an emulation session based on settings
351     in the configuration file "mysession". The -v option tells gxemul to be
352     verbose.
353
354           gxemul -v @mysession
355
356     If you have compiled the small Hello World program mentioned in the
357     gxemul documentation, the following command will start up an emulated
358     test machine in "paused" mode:
359
360           gxemul -E testmips -V hello_mips
361
362     Paused mode means that you enter the interactive single-step debugger
363     directly at startup, instead of launching the Hello World program.
364
365     The paused mode is also what should be used when running "unknown" files
366     for the first time in the emulator. E.g. if you have a binary which you
367     think is some kind of MIPS ROM image, then you can try the following:
368
369           gxemul -vv -E baremips -V 0xbfc00000:image.raw
370
371     You can then use the single-stepping functionality of the built-in debug‐
372     ger to run the code in the ROM image, to see how it behaves. Based on
373     that, you can deduce what machine type it was actually from (the baremips
374     machine is not a real machine), and perhaps try again with another emula‐
375     tion mode.
376
377     In general, however, real ROM images require much more emulation detail
378     than GXemul provides, so they can usually not run.
379
380     Please read the documentation for more details.
381

BUGS

383     There are many bugs. Some of the known bugs are mentioned in the TODO
384     file in the gxemul source distribution, some are marked as TODO in the
385     source code itself.
386
387     Userland (syscall-only) emulation, i.e. running a userland binary
388     directly without simulating an entire machine, doesn't really work yet.
389
390     gxemul is in general not cycle-accurate; it does not simulate individual
391     pipe-line stages or penalties caused by branch-prediction misses or cache
392     misses, so it cannot be used for accurate simulation of any actual real-
393     world processor.
394
395     gxemul is in general not timing-accurate. Many emulation modes try to
396     make the guest operating system's clock run at the same speed as the host
397     clock.  However, the number of instructions executed per clock tick can
398     obviously vary, depending on the current CPU load on the host.
399

AUTHOR

401     GXemul is Copyright (C) 2003-2009  Anders Gavare <anders@gavare.se>
402
403     See http://gavare.se/gxemul/ for more information. For other Copyright
404     messages, see the corresponding parts of the source code and/or documen‐
405     tation.
406
407BSD                              June 22, 2019                             BSD
Impressum