1 |
dpavlin |
20 |
.\" $Id: gxemul.1,v 1.39 2005/11/23 22:03:25 debug Exp $ |
2 |
dpavlin |
2 |
.\" |
3 |
|
|
.\" Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
4 |
|
|
.\" |
5 |
|
|
.\" Redistribution and use in source and binary forms, with or without |
6 |
|
|
.\" modification, are permitted provided that the following conditions are met: |
7 |
|
|
.\" |
8 |
|
|
.\" 1. Redistributions of source code must retain the above copyright |
9 |
|
|
.\" notice, this list of conditions and the following disclaimer. |
10 |
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright |
11 |
|
|
.\" notice, this list of conditions and the following disclaimer in the |
12 |
|
|
.\" documentation and/or other materials provided with the distribution. |
13 |
|
|
.\" 3. The name of the author may not be used to endorse or promote products |
14 |
|
|
.\" derived from this software without specific prior written permission. |
15 |
|
|
.\" |
16 |
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
17 |
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 |
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
19 |
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
20 |
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
21 |
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
22 |
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 |
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
24 |
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 |
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 |
|
|
.\" SUCH DAMAGE. |
27 |
|
|
.\" |
28 |
|
|
.\" |
29 |
|
|
.\" This is a minimal man page for GXemul. Process this file with |
30 |
|
|
.\" groff -man -Tascii gxemul.1 or nroff -man gxemul.1 |
31 |
|
|
.\" |
32 |
dpavlin |
20 |
.Dd NOVEMBER 2005 |
33 |
dpavlin |
2 |
.Dt GXEMUL 1 |
34 |
|
|
.Os |
35 |
|
|
.Sh NAME |
36 |
|
|
.Nm gxemul |
37 |
|
|
.Nd an experimental machine emulator |
38 |
|
|
.Sh SYNOPSIS |
39 |
|
|
.Nm |
40 |
|
|
.Op machine, other, and general options |
41 |
|
|
.Op file Ar ... |
42 |
|
|
.Nm |
43 |
|
|
.Op general options |
44 |
dpavlin |
14 |
.Ar @configfile |
45 |
dpavlin |
2 |
.Nm |
46 |
|
|
.Op userland, other, and general options |
47 |
|
|
.Ar file Op Ar args ... |
48 |
|
|
.Sh DESCRIPTION |
49 |
|
|
.Nm |
50 |
dpavlin |
14 |
is an experimental instruction-level machine emulator. Several |
51 |
|
|
emulation modes are available. In some modes, processors and surrounding |
52 |
|
|
hardware components are emulated well enough to let unmodified operating |
53 |
dpavlin |
20 |
systems (e.g. NetBSD) run inside the emulator as if they were running on a |
54 |
|
|
real machine. |
55 |
dpavlin |
2 |
.Pp |
56 |
dpavlin |
14 |
The processor architecture best emulated by GXemul is MIPS, but other |
57 |
dpavlin |
20 |
architectures (ARM and PowerPC) are also partially emulated. |
58 |
dpavlin |
12 |
.Pp |
59 |
dpavlin |
18 |
MIPS processors are emulated either using a simple type of binary |
60 |
|
|
translator (on Alpha and i386 hosts), or using traditional slow |
61 |
|
|
interpretation (all other hosts, including amd64 machines running in |
62 |
|
|
64-bit mode). |
63 |
|
|
.Pp |
64 |
dpavlin |
20 |
Non-MIPS processors are emulated using a newer dynamic |
65 |
dpavlin |
18 |
translation system (called dyntrans in the rest of this man page); |
66 |
|
|
dyntrans does not require any host-specific code, so it should work on any |
67 |
|
|
platform. Performance is somewhere between binary translation and |
68 |
|
|
traditional interpretation. |
69 |
|
|
.Pp |
70 |
dpavlin |
14 |
There are three ways to invoke the emulator: |
71 |
dpavlin |
2 |
.Pp |
72 |
dpavlin |
14 |
1. When emulating a complete machine, configuration options can be entered |
73 |
|
|
directly on the command line. |
74 |
|
|
.Pp |
75 |
|
|
2. Options can be read from a configuration file. |
76 |
|
|
.Pp |
77 |
|
|
3. When emulating a userland environment (syscall-only emulation, not |
78 |
|
|
emulating complete machines), then the program name and its argument |
79 |
|
|
should be given on the command line. (This mode doesn't really work yet.) |
80 |
|
|
.Pp |
81 |
dpavlin |
2 |
The easiest way to use the emulator is to supply settings directly on the |
82 |
|
|
command line. The most important thing you need to supply is the |
83 |
dpavlin |
14 |
file argument. This is the name of a binary file (an ELF, a.out, COFF/ECOFF, |
84 |
dpavlin |
2 |
SREC, or a raw binary image) which you wish to run in the emulator. This file |
85 |
|
|
might be an operating system kernel, or perhaps a ROM image file. |
86 |
|
|
.Pp |
87 |
|
|
If more than one filename is supplied, all files are loaded into memory, |
88 |
|
|
and the entry point (if available) is taken from the last file. |
89 |
|
|
.Pp |
90 |
|
|
Apart from the name of a binary file, it is also necessary to select |
91 |
|
|
which specific emulation mode to use. For example, a MIPS-based machine |
92 |
|
|
from DEC (a DECstation) is very different from a MIPS-based machine |
93 |
|
|
from SGI. Use |
94 |
|
|
.Nm |
95 |
|
|
.Fl H |
96 |
|
|
to get a list of available emulation modes. |
97 |
|
|
.Pp |
98 |
dpavlin |
6 |
There are two exceptions to the normal invocation usage mentioned above. |
99 |
|
|
The first is for DECstation emulation: if you have a bootable |
100 |
dpavlin |
2 |
DECstation harddisk or CDROM image, then just supplying the diskimage via |
101 |
|
|
the |
102 |
|
|
.Fl d |
103 |
dpavlin |
6 |
option is sufficient. (The filename of the kernel can then be |
104 |
dpavlin |
2 |
skipped, as the emulator runs the bootblocks from the diskimage directly and |
105 |
|
|
doesn't need the kernel as a separate file.) |
106 |
dpavlin |
6 |
The second is if you supply an ISO9660 CDROM disk image. You may then use |
107 |
|
|
the |
108 |
|
|
.Fl j |
109 |
|
|
option to indicate which file on the CDROM filesystem that should be |
110 |
|
|
loaded into emulated memory. |
111 |
dpavlin |
2 |
.Pp |
112 |
|
|
Machine selection options: |
113 |
|
|
.Bl -tag -width Ds |
114 |
|
|
.It Fl E Ar t |
115 |
|
|
Try to emulate machine type |
116 |
|
|
.Ar "t". |
117 |
dpavlin |
12 |
This option is not always needed, if the |
118 |
|
|
.Fl e |
119 |
|
|
option uniquely selects a machine. |
120 |
dpavlin |
2 |
(Use |
121 |
|
|
.Fl H |
122 |
|
|
to get a list of types.) |
123 |
|
|
.It Fl e Ar st |
124 |
|
|
Try to emulate machine subtype |
125 |
|
|
.Ar "st". |
126 |
|
|
Use this together with |
127 |
|
|
.Fl E . |
128 |
|
|
(This option is not always needed, if a machine type has no subtypes.) |
129 |
|
|
.El |
130 |
|
|
.Pp |
131 |
|
|
Other options: |
132 |
|
|
.Bl -tag -width Ds |
133 |
dpavlin |
12 |
.It Fl A |
134 |
|
|
Disable load/store alignment checks in some cases. This might give a small |
135 |
|
|
increase in performance, but the emulator will not run correctly if the |
136 |
dpavlin |
16 |
emulated code actually tries to do unaligned loads or stores. (This option |
137 |
|
|
is only meaningful when emulating MIPS CPUs, when the host architecture is |
138 |
|
|
Alpha or i386, and binary translation is enabled.) |
139 |
dpavlin |
2 |
.It Fl B |
140 |
dpavlin |
10 |
Disable dynamic binary translation. By default, bintrans |
141 |
|
|
will be turned on if the host+target architecture combination is |
142 |
dpavlin |
16 |
supported. Currently, the only supported target architecture for bintrans |
143 |
|
|
is MIPS, and the supported host architectures are Alpha and i386. |
144 |
dpavlin |
2 |
.It Fl C Ar x |
145 |
|
|
Try to emulate a specific CPU type, |
146 |
|
|
.Ar "x". |
147 |
|
|
This overrides the default CPU type for the machine being emulated. |
148 |
|
|
(Use |
149 |
|
|
.Fl H |
150 |
|
|
to get a list of available CPU types.) |
151 |
|
|
.It Fl d Ar name |
152 |
|
|
Add |
153 |
|
|
.Ar name |
154 |
|
|
as a disk image. By adding one or more modifier characters and then a |
155 |
|
|
colon (":") as a prefix to |
156 |
|
|
.Ar "name", |
157 |
dpavlin |
6 |
you can modify the way the disk image is treated. Available modifiers are: |
158 |
dpavlin |
2 |
.Bl -tag -width Ds |
159 |
|
|
.It b |
160 |
|
|
Specifies that this is a boot device. |
161 |
|
|
.It c |
162 |
dpavlin |
4 |
CD-ROM. |
163 |
dpavlin |
2 |
.It d |
164 |
dpavlin |
4 |
DISK (this is the default). |
165 |
|
|
.It f |
166 |
|
|
FLOPPY. |
167 |
dpavlin |
6 |
.It gH;S; |
168 |
|
|
Override the default geometry; use H heads and S sectors-per-track. |
169 |
|
|
(The number of cylinders is calculated automatically.) |
170 |
dpavlin |
2 |
.It i |
171 |
dpavlin |
4 |
IDE. |
172 |
dpavlin |
2 |
.It r |
173 |
|
|
Read-only (don't allow changes to be written to the file). |
174 |
dpavlin |
4 |
.It s |
175 |
|
|
SCSI (this is the default for most machine types). |
176 |
dpavlin |
2 |
.It t |
177 |
dpavlin |
4 |
Tape. |
178 |
dpavlin |
2 |
.It 0-7 |
179 |
dpavlin |
6 |
Force a specific ID number. |
180 |
dpavlin |
2 |
.El |
181 |
|
|
.Pp |
182 |
dpavlin |
14 |
Unless otherwise specified, filenames ending with ".iso" or ".cdr" are |
183 |
|
|
assumed to be CDROM images. Most others are assumed to be disks. Depending |
184 |
|
|
on which machine is being emulated, the default for disks can be either |
185 |
|
|
SCSI or IDE. Some disk images that are very small are assumed to be floppy |
186 |
|
|
disks. (If you are not happy with the way a disk image is detected, then |
187 |
|
|
you need to use explicit prefixes to force a specific type.) |
188 |
dpavlin |
6 |
.Pp |
189 |
|
|
For floppies, the gH;S; prefix is ignored. Instead, the number of |
190 |
|
|
heads and cylinders are assumed to be 2 and 80, respectively, and the |
191 |
|
|
number of sectors per track is calculated automatically. (This works for |
192 |
|
|
720KB, 1.2MB, 1.44MB, and 2.88MB floppies.) |
193 |
dpavlin |
2 |
.It Fl I Ar x |
194 |
|
|
Emulate clock interrupts at |
195 |
|
|
.Ar x |
196 |
|
|
Hz. (This affects emulated clock devices only, not actual runtime speed. |
197 |
|
|
This disables automatic clock adjustments, which is otherwise turned on.) |
198 |
|
|
(This option is probably only valid for DECstation emulation.) |
199 |
|
|
.It Fl i |
200 |
|
|
Display each instruction as it is being executed. |
201 |
|
|
.It Fl J |
202 |
dpavlin |
18 |
Disable some speed tricks. For MIPS emulation, these are mostly |
203 |
|
|
timing-related. For non-MIPS emulation (i.e. those modes using dyntrans), |
204 |
|
|
this flag disables the use of "instruction combinations". |
205 |
dpavlin |
2 |
.It Fl j Ar n |
206 |
|
|
Set the name of the kernel to |
207 |
|
|
.Ar "n". |
208 |
dpavlin |
10 |
When booting from an ISO9660 filesystem, the emulator will try to boot |
209 |
|
|
using this file. (In some emulation modes, eg. DECstation, this name is passed |
210 |
dpavlin |
6 |
along to the boot program. Useful names are "bsd" for OpenBSD/pmax, |
211 |
|
|
or "vmunix" for Ultrix.) |
212 |
dpavlin |
2 |
.It Fl M Ar m |
213 |
|
|
Emulate |
214 |
|
|
.Ar m |
215 |
|
|
MBs of physical RAM. This overrides the default amount of RAM for the |
216 |
|
|
selected machine type. |
217 |
|
|
.It Fl m Ar nr |
218 |
|
|
Run at most |
219 |
|
|
.Ar nr |
220 |
|
|
instructions (on any cpu). |
221 |
|
|
.It Fl N |
222 |
|
|
Display nr of instructions/second average, at regular intervals. |
223 |
|
|
.It Fl n Ar nr |
224 |
|
|
Set nr of CPUs (for SMP experiments). |
225 |
|
|
.It Fl O |
226 |
|
|
Force a "netboot" (tftp instead of disk), even when a disk image is |
227 |
|
|
present (for DECstation, SGI, and ARC emulation). |
228 |
|
|
.It Fl o Ar arg |
229 |
dpavlin |
16 |
Set the boot argument (mostly useful for DEC, ARC, or SGI emulation). |
230 |
dpavlin |
2 |
Default |
231 |
|
|
.Ar arg |
232 |
dpavlin |
16 |
for DEC is "-a", for ARC/SGI it is "-aN", and for CATS it is "-A". |
233 |
dpavlin |
2 |
.It Fl p Ar pc |
234 |
dpavlin |
6 |
Add a breakpoint. (Remember to use the "0x" prefix for hex.) |
235 |
dpavlin |
2 |
.It Fl Q |
236 |
|
|
Disable the built-in PROM emulation. This is useful for running raw ROM |
237 |
|
|
images from real machines. |
238 |
|
|
.It Fl R |
239 |
|
|
Use a random bootstrap cpu, instead of CPU nr 0. (For SMP experiments.) |
240 |
|
|
.It Fl r |
241 |
|
|
Dump register contents for every executed instruction. |
242 |
|
|
.It Fl S |
243 |
|
|
Initialize the emulated RAM to random data, instead of zeroes. |
244 |
|
|
.It Fl T |
245 |
|
|
Enter the single-step debugger on unimplemented memory accesses. |
246 |
|
|
.It Fl t |
247 |
|
|
Show a trace tree of all function calls being made. |
248 |
|
|
.It Fl U |
249 |
|
|
Enable slow_serial_interrupts_hack_for_linux. |
250 |
|
|
.It Fl X |
251 |
|
|
Use X11. |
252 |
|
|
.It Fl x |
253 |
|
|
Open up new xterms for emulated serial ports. (Default is to open up |
254 |
|
|
xterms when using configuration files, but not when starting an |
255 |
|
|
emulation with settings directly on the command line.) |
256 |
|
|
.It Fl Y Ar n |
257 |
|
|
Scale down framebuffer windows by |
258 |
|
|
.Ar n |
259 |
|
|
x |
260 |
|
|
.Ar n |
261 |
dpavlin |
20 |
times. This option is useful when emulating a very large framebuffer, and |
262 |
|
|
the actual display is of lower resolution. If |
263 |
|
|
.Ar n |
264 |
|
|
is negative, then there will be no scaledown, but emulation of certain |
265 |
|
|
graphic controllers will be scaled up |
266 |
|
|
by |
267 |
|
|
.Ar -n |
268 |
|
|
times instead. E.g. Using |
269 |
|
|
.Ar -2 |
270 |
|
|
with VGA text mode emulation will result in 80x25 character cells rendered |
271 |
|
|
in a 1280x800 window, instead of the normal resolution of 640x400. |
272 |
dpavlin |
2 |
.It Fl y Ar x |
273 |
|
|
Set max_random_cycles_per_chunk to |
274 |
|
|
.Ar x |
275 |
|
|
(experimental). |
276 |
|
|
.It Fl Z Ar n |
277 |
|
|
Set the number of graphics cards, for emulating a dual-head or tripple-head |
278 |
|
|
environment. (Only for DECstation emulation so far.) |
279 |
|
|
.It Fl z Ar disp |
280 |
|
|
Add |
281 |
|
|
.Ar disp |
282 |
|
|
as an X11 display to use for framebuffers. |
283 |
|
|
.El |
284 |
|
|
.Pp |
285 |
|
|
Userland options: |
286 |
|
|
.Bl -tag -width Ds |
287 |
|
|
.It Fl u Ar emul-mode |
288 |
|
|
Userland-only (syscall) emulation. (Use |
289 |
|
|
.Fl H |
290 |
|
|
to get a list of available emulation modes.) Some (but not all) of the |
291 |
|
|
options listed under Other options above can also be used with userland |
292 |
|
|
emulation. |
293 |
|
|
.El |
294 |
|
|
.Pp |
295 |
|
|
General options: |
296 |
|
|
.Bl -tag -width Ds |
297 |
|
|
.It Fl D |
298 |
dpavlin |
6 |
Guarantee fully deterministic behavior. Normally, the emulator calls |
299 |
dpavlin |
2 |
srandom() with a seed based on the current time at startup. When the |
300 |
|
|
.Fl D |
301 |
|
|
option is used, the srandom() call is skipped, which should cause two |
302 |
dpavlin |
6 |
subsequent invocations of the emulator to be identical, if all other |
303 |
|
|
settings are identical and no user input is taking place. (If this option |
304 |
|
|
is used, then |
305 |
dpavlin |
2 |
.Fl I |
306 |
|
|
must also be used.) |
307 |
|
|
.It Fl H |
308 |
|
|
Display a list of available CPU types, machine types, and userland |
309 |
|
|
emulation modes. (Most of these don't work. Please read the documentation |
310 |
|
|
included in the |
311 |
|
|
.Nm |
312 |
|
|
distribution for details on which modes that actually work.) |
313 |
|
|
.It Fl h |
314 |
|
|
Display a list of all available command line options. |
315 |
|
|
.It Fl K |
316 |
|
|
Force the single-step debugger to be entered at the end of a simulation. |
317 |
|
|
.It Fl q |
318 |
|
|
Quiet mode; this suppresses startup messages. |
319 |
|
|
.It Fl s |
320 |
dpavlin |
18 |
For MIPS emulation: Show opcode usage statistics after the simulation. |
321 |
|
|
For non-MIPS emulation (i.e. using dyntrans): Save statistics to a file at |
322 |
|
|
regular intervals of which physical addresses that were executed. |
323 |
dpavlin |
2 |
.It Fl V |
324 |
|
|
Start up in the single-step debugger, paused. |
325 |
|
|
.It Fl v |
326 |
|
|
Verbose debug messages. |
327 |
|
|
.El |
328 |
|
|
.Pp |
329 |
|
|
Configuration file startup: |
330 |
|
|
.Bl -tag -width Ds |
331 |
|
|
.It @ Ar configfile |
332 |
|
|
Start an emulation based on the contents of |
333 |
|
|
.Ar "configfile". |
334 |
|
|
.El |
335 |
|
|
.Pp |
336 |
|
|
For more information, please read the documentation in the doc/ |
337 |
|
|
subdirectory of the |
338 |
|
|
.Nm |
339 |
|
|
distribution. |
340 |
|
|
.Sh EXAMPLES |
341 |
|
|
The following command will start NetBSD/pmax on an emulated DECstation |
342 |
dpavlin |
10 |
5000/200 (3MAX): |
343 |
dpavlin |
2 |
.Pp |
344 |
dpavlin |
12 |
.Dl "gxemul -e 3max -d nbsd_pmax.img" |
345 |
dpavlin |
2 |
.Pp |
346 |
dpavlin |
10 |
nbsd_pmax.img should be a raw disk image containing a bootable |
347 |
dpavlin |
2 |
NetBSD/pmax filesystem. |
348 |
|
|
.Pp |
349 |
|
|
The following command will start an emulation session based on settings in |
350 |
|
|
the configuration file "mysession". The -v option tells gxemul to be |
351 |
|
|
verbose. |
352 |
|
|
.Pp |
353 |
|
|
.Dl "gxemul -v @mysession" |
354 |
|
|
.Pp |
355 |
|
|
If you have compiled the small Hello World program mentioned in the |
356 |
|
|
.Nm |
357 |
|
|
documentation, the following command will start up an |
358 |
|
|
emulated test machine in "paused" mode: |
359 |
|
|
.Pp |
360 |
|
|
.Dl "gxemul -E testmips -V hello_mips" |
361 |
|
|
.Pp |
362 |
|
|
(Paused mode means that you enter the interactive single-step debugger |
363 |
|
|
directly at startup, instead of launching the Hello World program.) |
364 |
|
|
.Pp |
365 |
|
|
Please read the documentation for more details. |
366 |
|
|
.Sh BUGS |
367 |
|
|
There are many bugs. Some of the known bugs are listed in the BUGS |
368 |
|
|
file in the |
369 |
|
|
.Nm |
370 |
dpavlin |
12 |
source distribution, some are indirectly mentioned in the TODO file, |
371 |
|
|
and some are mentioned in the source code itself. |
372 |
dpavlin |
2 |
.Pp |
373 |
dpavlin |
10 |
The binary translation subsystem is really terrible, but it is less |
374 |
|
|
terrible than running without it. |
375 |
dpavlin |
2 |
.Pp |
376 |
dpavlin |
12 |
Userland (syscall-only) emulation doesn't really work yet. |
377 |
|
|
.Pp |
378 |
dpavlin |
16 |
Emulation of MIPS CPUs is done differently from other emulation modes; the |
379 |
dpavlin |
20 |
documentation sometimes only reflects the way things work with MIPS |
380 |
dpavlin |
16 |
emulation, and it is incorrect when applied to e.g. ARM emulation. |
381 |
|
|
.Pp |
382 |
dpavlin |
2 |
.Nm |
383 |
|
|
does not simulate individual pipe-line stages or penalties caused by |
384 |
dpavlin |
14 |
branch-prediction misses or cache misses, so it cannot be used for |
385 |
|
|
accurate simulation of any actual real-world processor. |
386 |
dpavlin |
6 |
.Pp |
387 |
|
|
.Nm |
388 |
|
|
is not timing-accurate. |
389 |
dpavlin |
2 |
.Sh AUTHOR |
390 |
|
|
Anders Gavare <anders@gavare.se> |
391 |
|
|
.Pp |
392 |
|
|
See http://gavare.se/gxemul/ for more information. |