1 |
<html> |
<html><head><title>Gavare's eXperimental Emulator: Introduction</title> |
2 |
<head><title>GXemul documentation: Introduction</title> |
<meta name="robots" content="noarchive,nofollow,noindex"></head> |
|
</head> |
|
3 |
<body bgcolor="#f8f8f8" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000"> |
<body bgcolor="#f8f8f8" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000"> |
4 |
<table border=0 width=100% bgcolor="#d0d0d0"><tr> |
<table border=0 width=100% bgcolor="#d0d0d0"><tr> |
5 |
<td width=100% align=center valign=center><table border=0 width=100%><tr> |
<td width=100% align=center valign=center><table border=0 width=100%><tr> |
6 |
<td align="left" valign=center bgcolor="#d0efff"><font color="#6060e0" size="6"> |
<td align="left" valign=center bgcolor="#d0efff"><font color="#6060e0" size="6"> |
7 |
<b>GXemul documentation:</b></font> |
<b>Gavare's eXperimental Emulator: </b></font> |
8 |
<font color="#000000" size="6"><b>Introduction</b> |
<font color="#000000" size="6"><b>Introduction</b> |
9 |
</font></td></tr></table></td></tr></table><p> |
</font></td></tr></table></td></tr></table><p> |
|
<!-- The first 10 lines are cut away by the homepage updating script. --> |
|
|
|
|
10 |
|
|
11 |
<!-- |
<!-- |
12 |
|
|
13 |
$Id: intro.html,v 1.46 2005/06/04 12:02:17 debug Exp $ |
$Id: intro.html,v 1.66 2005/11/23 22:03:24 debug Exp $ |
14 |
|
|
15 |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
16 |
|
|
53 |
<li><a href="#cpus">Which CPU types does GXemul emulate?</a> |
<li><a href="#cpus">Which CPU types does GXemul emulate?</a> |
54 |
<li><a href="#accuracy">Emulation accuracy</a> |
<li><a href="#accuracy">Emulation accuracy</a> |
55 |
<li><a href="#emulmodes">Which machines does GXemul emulate?</a> |
<li><a href="#emulmodes">Which machines does GXemul emulate?</a> |
56 |
<li><a href="#guestos">Which guest OSes are possible to run?</a> |
<li><a href="#guestos">Which guest OSes are possible to run in GXemul?</a> |
57 |
</ul> |
</ul> |
58 |
|
|
59 |
|
|
64 |
<a name="overview"></a> |
<a name="overview"></a> |
65 |
<h3>Overview:</h3> |
<h3>Overview:</h3> |
66 |
|
|
67 |
GXemul is a machine emulator, which can be used to experiment with |
GXemul is an experimental instruction-level machine emulator. Several |
68 |
binary code for (among others) MIPS-based machines. Several emulation |
emulation modes are available. In some modes, processors and surrounding |
|
modes are available. For some emulation modes, processors and surrounding |
|
69 |
hardware components are emulated well enough to let unmodified operating |
hardware components are emulated well enough to let unmodified operating |
70 |
systems run as if they were running on a real machine. |
systems (e.g. NetBSD) run as if they were running on a real machine. |
71 |
|
|
72 |
<p> |
<p>The processor architecture best emulated by GXemul is MIPS, but other |
73 |
Devices and CPUs are not simulated with 100% accuracy. They are only |
architectures such as ARM and PowerPC are also partially emulated. |
74 |
"faked" well enough to make operating systems (eg NetBSD) run without |
|
75 |
|
<p>Devices and CPUs are not simulated with 100% accuracy. They are only |
76 |
|
``faked'' well enough to allow guest operating systems run without |
77 |
complaining too much. Still, the emulator could be of interest for |
complaining too much. Still, the emulator could be of interest for |
78 |
academic research and experiments, such as when learning how to write |
academic research and experiments, such as when learning how to write |
79 |
operating system code. |
operating system code. |
80 |
|
|
81 |
<p> |
<p>The emulator is written in C, does not depend on third-party libraries |
82 |
The emulator is written in C, does not depend on external libraries (except |
(except X11, but that is optional), and should compile and run on most |
83 |
X11, but that is optional), and should compile and run on most Unix-like |
Unix-like systems. |
84 |
systems. If it doesn't, then that is a bug. |
|
85 |
(You do not need any MIPS compiler toolchain to build or use GXemul. |
<p>The emulator contains code which tries to emulate the workings of CPUs |
86 |
If you need to compile MIPS binaries from sources, then of course you need |
and surrounding hardware found in real machines, but it does not contain |
87 |
such a toolchain, but that is completely separate from GXemul.) |
any ROM code. You will need some form of program (in binary form) to run |
88 |
|
in the emulator. For many emulation modes, PROM calls are handled by the |
|
<p> |
|
|
The emulator contains code which tries to emulate the workings of CPUs and |
|
|
surrounding hardware found in real machines, but it does not contain any |
|
|
ROM code. You will need some form of program (in binary form) to run in |
|
|
the emulator. For many emulation modes, PROM calls are handled by the |
|
89 |
emulator itself, so you do not need to use any ROM image at all. |
emulator itself, so you do not need to use any ROM image at all. |
90 |
|
|
91 |
<p> |
<p>You can use pre-compiled kernels (for example NetBSD kernels, or |
92 |
You can use pre-compiled kernels (for example NetBSD kernels, or Linux), |
Linux), or other programs that are in binary format, and in some cases |
93 |
or other programs that are in binary format, and in some cases even actual |
even actual ROM images. A couple of different file formats are supported |
94 |
ROM images. A couple of different file formats are supported (ELF, a.out, |
(ELF, a.out, ECOFF, SREC, and raw binaries). |
|
ECOFF, SREC, and raw binaries). |
|
95 |
|
|
96 |
<p> |
<p>If you do not have a kernel as a separate file, but you have a bootable |
|
If you do not have a kernel as a separate file, but you have a bootable |
|
97 |
disk image, then it is sometimes possible to boot directly from that |
disk image, then it is sometimes possible to boot directly from that |
98 |
image. (This works for example with DECstation emulation, or when booting |
image. (This works for example with DECstation emulation, or when booting |
99 |
from ISO9660 CDROM images.) |
from ISO9660 CDROM images.) |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
<p><br> |
<p><br> |
109 |
<a name="free"></a> |
<a name="free"></a> |
110 |
<h3>Is GXemul Free software?</h3> |
<h3>Is GXemul Free software?</h3> |
115 |
four freedoms associated with Free software, <a |
four freedoms associated with Free software, <a |
116 |
href="http://www.gnu.org/philosophy/free-sw.html">http://www.gnu.org/philosophy/free-sw.html</a>.) |
href="http://www.gnu.org/philosophy/free-sw.html">http://www.gnu.org/philosophy/free-sw.html</a>.) |
117 |
|
|
118 |
<p> |
<p>The code I have written is released under a 3-clause BSD-style license |
119 |
The code I have written is released under a 3-clause BSD-style license |
(or "revised BSD-style" if one wants to use <a |
120 |
(or "revised BSD-style" if one wants to use |
href="http://www.gnu.org/philosophy/bsd.html">GNU jargon</a>). Apart from |
121 |
<a href="http://www.gnu.org/philosophy/bsd.html">GNU jargon</a>). |
the code I have written, some files are copied from other sources such as |
122 |
Apart from the code I have written, some files are copied from other sources |
NetBSD, for example header files containing symbolic names of bitfields in |
123 |
such as NetBSD, for example header files containing symbolic names of |
device registers. They are also covered by similar licenses, but with some |
124 |
bitfields in device registers. They are also covered by similar licenses, |
additional clauses. The main point, however, is that the licenses require |
125 |
but with some additional clauses. If you plan to redistribute GXemul |
that the original Copyright and license terms are included when you make a |
126 |
(for example as a binary package), or reuse code from GXemul, |
copy or modification. |
127 |
then you should check those files for their license terms. |
|
128 |
|
<p>If you plan to redistribute GXemul <i>without</i> supplying the source |
129 |
|
code, then you need to comply with each individual source file some other |
130 |
|
way, for example by writing additional documentation containing copyright |
131 |
|
notes. I have not done this, since I do not plan on making distributions |
132 |
|
without source code. You need to check all individual files for details. |
133 |
|
The "easiest way out" if you plan to redistribute code from GXemul is, of |
134 |
|
course, to let it remain open source and simply supply the source code. |
135 |
|
|
136 |
|
<p>(If a stable, unmodified release of GXemul is packaged into binary form, |
137 |
|
and it is clear which version of GXemul was used to build the package, |
138 |
|
then it can be argued that the source code is available, just not in that |
139 |
|
specific package. Common sense should be used in this case, and not |
140 |
|
pedanticism.) |
141 |
|
|
|
<p> |
|
|
(The licenses usually require that the original Copyright and license |
|
|
terms are included when you make a copy or modification. The "easiest way |
|
|
out" if you plan to redistribute code from GXemul is to simply supply |
|
|
the source code. You should however check individual files for details.) |
|
142 |
|
|
143 |
|
|
144 |
|
|
154 |
$ <b>make</b> |
$ <b>make</b> |
155 |
</pre> |
</pre> |
156 |
|
|
157 |
<p> |
<p>This should work on most Unix-like systems. If it doesn't, then |
|
This should work on most Unix-like systems. If it doesn't, then |
|
158 |
mail me a bug report. |
mail me a bug report. |
159 |
|
|
160 |
<p> |
<p>The emulator's performance is highly dependent on both runtime settings |
|
(Note for Windows users: there is a possibility that some releases |
|
|
and/or snapshots will also work with Cygwin, but I can't promise that.) |
|
|
|
|
|
<p> |
|
|
The emulator's performance is highly dependent on both runtime settings |
|
161 |
and on compiler settings, so you might want to experiment with different |
and on compiler settings, so you might want to experiment with different |
162 |
CC and CFLAGS environment variable values. For example, on a modern PC, |
CC and CFLAGS environment variable values. For example, on an AMD Athlon |
163 |
you could try the following: |
host, you might want to try setting <tt>CFLAGS</tt> to <tt>-march=athlon |
164 |
<p> |
-O3</tt> before running <tt>configure</tt>. |
|
<pre> |
|
|
$ <b>CFLAGS="-mcpu=pentium4 -O3" ./configure</b> |
|
|
$ <b>make</b> |
|
|
</pre> |
|
165 |
|
|
|
<p> |
|
|
Run <b><tt>./configure --help</tt></b> to get a list of configure options. (The |
|
|
possible options differ between different releases and snapshots.) |
|
166 |
|
|
167 |
|
|
168 |
|
|
219 |
Emulation of R4000, which is a 64-bit CPU, was my initial goal. |
Emulation of R4000, which is a 64-bit CPU, was my initial goal. |
220 |
R2000/R3000-like CPUs (32-bit), R1x000, and generic MIPS32/MIPS64-style |
R2000/R3000-like CPUs (32-bit), R1x000, and generic MIPS32/MIPS64-style |
221 |
CPUs are also emulated, and are hopefully almost as stable as the R4000 |
CPUs are also emulated, and are hopefully almost as stable as the R4000 |
222 |
emulation. |
emulation. Several guest operating systems for MIPS can run inside |
223 |
|
the emulator. |
|
<p> |
|
|
I have written an experimental dynamic binary translation subsystem. |
|
|
This gives higher total performance than interpreting one instruction at a |
|
|
time and executing it. (If you wish to enable bintrans, add <b>-b</b> to |
|
|
the command line, but keep in mind that it is still experimental.) |
|
|
|
|
|
|
|
|
<h4>URISC:</h4> |
|
224 |
|
|
225 |
I have implemented an <a href="http://en.wikipedia.org/wiki/URISC">URISC</a> |
<p>(For MIPS emulation, I have written an experimental dynamic binary |
226 |
emulation mode, just for fun. The only instruction available in an URISC |
translation subsystem, for Alpha and i386 hosts. This gives higher total |
227 |
machine is "reverse subtract and skip on borrow". (It is probably not |
performance than interpreting one instruction at a time and executing it. |
228 |
worth trying to do bintrans with URISC, because any reasonable URISC |
If you wish to disable bintrans, add <b>-B</b> to the command line.) |
|
program relies on self-modifying code, which is bad for bintrans |
|
|
performance.) |
|
229 |
|
|
230 |
|
<h4>ARM:</h4> |
231 |
|
|
232 |
<h4>POWER/PowerPC</h4> |
ARM emulation is good enough to run NetBSD/cats 2.1 and OpenBSD/cats 3.8, |
233 |
|
but it is not as tested or fine-tuned as the MIPS emulation mode. |
234 |
|
|
235 |
There is some code for 64-bit (and 32-bit) POWER/PowerPC emulation, enough |
<h4>PowerPC:</h4> |
|
to run "Hello World", but not enough to run complete operating systems. |
|
|
This mode isn't really working yet. |
|
236 |
|
|
237 |
|
PowerPC emulation is still in its beginning stages, but good enough |
238 |
|
to run NetBSD/prep 2.1. |
239 |
|
|
240 |
<h4>Other CPU types:</h4> |
<p>Non-MIPS emulation modes use dynamic translation, but not recompilation |
241 |
|
into native code. This makes it possible to run on any host platform. |
|
Some other CPU architectures (such as x86) can also be partially emulated. |
|
|
These are not enabled by default though, because of their unstable-ness. |
|
242 |
|
|
243 |
|
|
244 |
|
|
254 |
to be enough to be able to run complete guest operating systems inside the |
to be enough to be able to run complete guest operating systems inside the |
255 |
emulator. |
emulator. |
256 |
|
|
257 |
<p> |
<p>Caches are by default not emulated. In some cases, the existance of |
258 |
Caches are by default not emulated. In some cases, the existance of caches |
caches is "faked" to let operating systems think that they are there. |
259 |
is "faked" to let operating systems think that they are there. (There is |
(There is some old code for R2000/R3000 caches, but it has probably |
260 |
some old code for R2000/R3000 caches, but it has probably suffered from |
suffered from bitrot by now.) |
261 |
bitrot by now.) |
|
262 |
|
<p>The emulator is <i>not</i> timing-accurate. It can be run in a |
263 |
|
"deterministic" mode, <tt><b>-D</b></tt>. The meaning of deterministic is |
264 |
|
simply that running two emulations with the same settings will result in |
265 |
|
identical runs. Obviously, this requires that no user interaction is |
266 |
|
taking place, and that clock speeds are fixed with the <tt><b>-I</b></tt> |
267 |
|
option. (Deterministic in this case does <i>not</i> mean that the |
268 |
|
emulation will be identical to some actual real-world machine.) |
269 |
|
|
270 |
|
<p><font color="#ff0000">(Oops/TODO: User interaction means <i>both</i> |
271 |
|
input to the emulated program/OS, and interacting with the emulator |
272 |
|
itself. Breaking into the debugger and then continuing execution may |
273 |
|
affect when/how interrupts occur.)</font> |
274 |
|
|
|
<p> |
|
|
The emulator is <i>not</i> timing-accurate. It can be run in a |
|
|
"deterministic" mode, <tt><b>-D</b></tt>. The meaning of deterministic is |
|
|
simply that running two emulations with the same settings will result in |
|
|
identical runs. Obviously, this requires that no user interaction is |
|
|
taking place, and that clock speeds are fixed with the <tt><b>-I</b></tt> |
|
|
option. (Deterministic in this case does <i>not</i> mean that the emulation |
|
|
will be identical to some actual real-world machine.) |
|
275 |
|
|
276 |
|
|
277 |
|
|
286 |
|
|
287 |
<p> |
<p> |
288 |
<ul> |
<ul> |
289 |
<li><b>DECstation 5000/200</b> ("3max") |
<li><b><u>MIPS</u></b> |
290 |
<br>Serial controller (including keyboard and mouse), ethernet, |
<ul> |
291 |
SCSI, and graphical framebuffers. |
<li><b>DECstation 5000/200</b> ("3max") |
292 |
<p> |
<p> |
293 |
<li><b>Acer Pica-61</b> (an ARC machine) |
<li><b>Acer Pica-61</b> (an ARC machine) |
294 |
<br>Serial controller, "VGA" text console, and SCSI. |
<p> |
295 |
|
<li><b>NEC MobilePro 770, 780, 800, and 880</b> (HPCmips machines) |
296 |
|
<p> |
297 |
|
<li><b>Cobalt</b> |
298 |
|
<p> |
299 |
|
<li><b>Malta</b> (evbmips) |
300 |
|
<p> |
301 |
|
<li><b>SGI O2 ("IP32")</b> |
302 |
|
<br><small>(Enough for root-on-nfs, but not for disk boot.)</small> |
303 |
|
</ul> |
304 |
<p> |
<p> |
305 |
<li><b>NEC MobilePro 770, 780, 800, and 880</b> (HPCmips machines) |
<li><b><u>ARM</u></b> |
306 |
<br>Framebuffer, keyboard, and a PCMCIA IDE controller. |
<ul> |
307 |
|
<li><b>CATS</b> |
308 |
|
</ul> |
309 |
<p> |
<p> |
310 |
<li><b>Cobalt</b> |
<li><b><u>PowerPC</u></b> |
311 |
<br>Serial controller and PCI IDE. |
<ul> |
312 |
|
<li><b>PReP (PowerPC Reference Platform)</b> |
313 |
|
</ul> |
314 |
</ul> |
</ul> |
315 |
|
|
316 |
<p> |
<p>There is code in GXemul for emulation of many other machine types; the |
317 |
There is code in GXemul for emulation of many other machine types; |
degree to which these work range from almost being able to run a complete |
318 |
the degree to which these work range from "almost" being able to run |
OS, to almost completely unsupported (perhaps just enough support to |
319 |
a complete OS, to almost completely unsupported (perhaps just enough |
output a few boot messages via serial console). |
320 |
support to output a few boot messages via serial console). |
|
321 |
|
<p>In addition to emulating real machines, there is also a "test-machine". |
322 |
<p> |
A test-machine consists of one or more CPUs and a few experimental devices |
323 |
In addition to emulating real machines, there is also a "test-machine". |
such as: |
|
A test-machine consists of one or more CPUs and a few experimental |
|
|
devices such as: |
|
324 |
|
|
325 |
<p> |
<p> |
326 |
<ul> |
<ul> |
327 |
<li>a console I/O device (putchar() and getchar()...) |
<li>a console I/O device (putchar() and getchar()...) |
328 |
<li>an inter-processor communication device, for SMP experiments |
<li>an inter-processor communication device, for SMP experiments |
329 |
<li>a very simple linear framebuffer device (for graphics output) |
<li>a very simple linear framebuffer device (for graphics output) |
330 |
|
<li>a simple SCSI disk controller |
331 |
|
<li>a simple ethernet controller |
332 |
</ul> |
</ul> |
333 |
|
|
334 |
<p> |
<p>This mode is useful if you wish to run experimental code, but do not |
|
This mode is useful if you wish to run experimental code, but do not |
|
335 |
wish to target any specific real-world machine type, for example for |
wish to target any specific real-world machine type, for example for |
336 |
educational purposes. |
educational purposes. |
337 |
|
|
338 |
<p> |
<p>You can read more about these experimental devices <a |
339 |
You can read more about these experimental devices |
href="experiments.html#expdevices">here</a>. |
|
<a href="experiments.html#expdevices">here</a>. |
|
340 |
|
|
341 |
|
|
342 |
|
|
346 |
|
|
347 |
<p><br> |
<p><br> |
348 |
<a name="guestos"></a> |
<a name="guestos"></a> |
349 |
<h3>Which guest OSes are possible to run?</h3> |
<h3>Which guest OSes are possible to run in GXemul?</h3> |
350 |
|
|
351 |
This table lists the guest OSes that run well enough to be considered |
This table lists the guest OSes that run well enough to be considered |
352 |
working in the emulator. They can boot from a harddisk image and be |
working in the emulator. They can boot from a harddisk image and be |
427 |
<br>Cobalt</td> |
<br>Cobalt</td> |
428 |
</tr> |
</tr> |
429 |
|
|
430 |
|
<tr><td height="10"></td></tr> |
431 |
|
|
432 |
|
<tr> |
433 |
|
<td></td> |
434 |
|
<td align="center"><a href="20050626-netbsd-sgimips-netboot.png"><img src="20050626-netbsd-sgimips-netboot_small.png"></a></td> |
435 |
|
<td></td> |
436 |
|
<td><a href="http://www.netbsd.org/Ports/sgimips/">NetBSD/sgimips</a> |
437 |
|
<br>SGI O2 ("IP32")</td> |
438 |
|
<td></td> |
439 |
|
<td align="center"><a href="20050622-netbsd-evbmips-malta.png"><img src="20050622-netbsd-evbmips-malta_small.png"></a></td> |
440 |
|
<td></td> |
441 |
|
<td><a href="http://www.netbsd.org/Ports/evbmips/">NetBSD/evbmips</a> |
442 |
|
<br>5Kc (and 4Kc) Malta<br>evaluation boards</td> |
443 |
|
<td></td> |
444 |
|
</tr> |
445 |
|
|
446 |
|
<tr><td height="10"></td></tr> |
447 |
|
|
448 |
|
<tr> |
449 |
|
<td></td> |
450 |
|
<td align="center"><a href="20051007-netbsd-cats-installed.png"><img src="20051007-netbsd-cats-installed_small.png"></a></td> |
451 |
|
<td></td> |
452 |
|
<td><a href="http://www.netbsd.org/Ports/cats/">NetBSD/cats</a> |
453 |
|
<br>CATS</td> |
454 |
|
<td></td> |
455 |
|
<td align="center"><a href="20051007-openbsd-cats-installed.png"><img src="20051007-openbsd-cats-installed_small.png"></a></td> |
456 |
|
<td></td> |
457 |
|
<td><a href="http://www.openbsd.org/cats.html">OpenBSD/cats</a> |
458 |
|
<br>CATS</td> |
459 |
|
<td></td> |
460 |
|
</tr> |
461 |
|
|
462 |
|
<tr><td height="10"></td></tr> |
463 |
|
|
464 |
|
<tr> |
465 |
|
<td></td> |
466 |
|
<td align="center"><a href="20051123-netbsd-prep.png"><img src="20051123-netbsd-prep_small.png"></a></td> |
467 |
|
<td></td> |
468 |
|
<td><a href="http://www.netbsd.org/Ports/prep/">NetBSD/prep</a> |
469 |
|
<br>PReP</td> |
470 |
|
<td></td> |
471 |
|
</tr> |
472 |
|
|
473 |
</table></center> |
</table></center> |
474 |
|
|
475 |
|
|