1 |
<html> |
2 |
<head><title>GXemul documentation: Introduction</title> |
3 |
</head> |
4 |
<body bgcolor="#ffffff" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000"> |
5 |
<p> |
6 |
<table width="100%"> |
7 |
<tr><td width="100%" bgcolor="#808070"><font color="#ffffe0" size="6"> |
8 |
<b>GXemul documentation: Introduction</b></font></td></tr> |
9 |
</table> |
10 |
<p> |
11 |
<!-- The first 10 lines are cut away by the homepage updating script. --> |
12 |
|
13 |
|
14 |
<!-- |
15 |
|
16 |
$Id: intro.html,v 1.30 2005/04/07 15:43:15 debug Exp $ |
17 |
|
18 |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
19 |
|
20 |
Redistribution and use in source and binary forms, with or without |
21 |
modification, are permitted provided that the following conditions are met: |
22 |
|
23 |
1. Redistributions of source code must retain the above copyright |
24 |
notice, this list of conditions and the following disclaimer. |
25 |
2. Redistributions in binary form must reproduce the above copyright |
26 |
notice, this list of conditions and the following disclaimer in the |
27 |
documentation and/or other materials provided with the distribution. |
28 |
3. The name of the author may not be used to endorse or promote products |
29 |
derived from this software without specific prior written permission. |
30 |
|
31 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
32 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
33 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
34 |
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
35 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
36 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
37 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
38 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
39 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
40 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
41 |
SUCH DAMAGE. |
42 |
|
43 |
--> |
44 |
|
45 |
<a href="./">Back to the index</a> |
46 |
|
47 |
<p><br> |
48 |
<h2>Introduction</h2> |
49 |
|
50 |
<p> |
51 |
<ul> |
52 |
<li><a href="#overview">Overview</a> |
53 |
<li><a href="#free">Is GXemul free software?</a> |
54 |
<li><a href="#build">How to compile/build the emulator</a> |
55 |
<li><a href="#cpus">Which CPU types does GXemul emulate?</a> |
56 |
<li><a href="#accuracy">Emulation accuracy</a> |
57 |
<li><a href="#emulmodes">Which machines does GXemul emulate?</a> |
58 |
<li><a href="#guestos">Which guest OSes are possible to run?</a> |
59 |
</ul> |
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
<p><br> |
66 |
<a name="overview"></a> |
67 |
<h3>Overview:</h3> |
68 |
|
69 |
GXemul is a machine emulator, which can be used to experiment with |
70 |
binary code for (among others) MIPS-based machines. Several emulation |
71 |
modes are available. For some emulation modes, processors and surrounding |
72 |
hardware components are emulated well enough to let unmodified operating |
73 |
systems run as if they were running on a real machine. |
74 |
|
75 |
<p> |
76 |
It is important to keep in mind that devices and CPUs are not really |
77 |
emulated correctly, they are only "faked" well enough to make eg. NetBSD |
78 |
run. Still, the emulator could be of interest for academic research and |
79 |
experiments, such as when learning how to write an OS for a real machine, |
80 |
or profiling SMP, memory, or system call usage. |
81 |
|
82 |
<p> |
83 |
The emulator is written in C, does not depend on external libraries (except |
84 |
X11, but that is optional), and should compile and run on most Unix-like |
85 |
systems. If it doesn't, then that is a bug. |
86 |
|
87 |
<p> |
88 |
The emulator contains code which tries to emulate the workings of CPUs and |
89 |
surrounding hardware found in real machines, but it does not contain any |
90 |
ROM code. You will need some form of program (in binary form) to run in |
91 |
the emulator. For many emulation modes, PROM calls are handled by the |
92 |
emulator itself, so you do not need to use any ROM image at all. |
93 |
|
94 |
<p> |
95 |
You can use pre-compiled kernels (for example NetBSD kernels, or Linux), |
96 |
or other programs that are in binary format, and in some cases even actual |
97 |
ROM images. A couple of different file formats are supported (ELF, a.out, |
98 |
ECOFF, SREC, raw binaries). |
99 |
|
100 |
<p> |
101 |
(You do not need any MIPS compiler toolchain to build or use GXemul. |
102 |
If you need to compile MIPS binaries from sources, then of course you need |
103 |
such a toolchain, but that is completely separate from GXemul. There |
104 |
is a <a href="technical.html#regtest">regression testing</a> framework, |
105 |
which requires that a GNU CC for mips64-unknown-elf or similar is available. |
106 |
For simply building and using the emulator, it is not required.) |
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
<p><br> |
113 |
<a name="free"></a> |
114 |
<h3>Is GXemul free software?</h3> |
115 |
|
116 |
Yes. I have released GXemul under a free license. |
117 |
(For a definitions of the four freedoms associated with free software, |
118 |
please read <a href="http://www.gnu.org/philosophy/free-sw.html"> |
119 |
http://www.gnu.org/philosophy/free-sw.html</a>.) |
120 |
|
121 |
<p> |
122 |
The code I have written is released under a 3-clause BSD-style license |
123 |
(or "revised BSD-style" if one wants to use |
124 |
<a href="http://www.gnu.org/philosophy/bsd.html">GNU jargon</a>.) |
125 |
Apart from the code I have written, some files are copied from other sources |
126 |
such as NetBSD, for example header files containing symbolic names of |
127 |
bitfields in device registers. They are also covered by similar licenses, |
128 |
but with some additional clauses. If you plan to redistribute GXemul |
129 |
(for example as a binary package), or reuse code from GXemul, |
130 |
then you should check those files for their license terms. |
131 |
|
132 |
<p> |
133 |
(The licenses usually require that the original Copyright and license |
134 |
terms are included when you make a copy or modification. The "easiest way |
135 |
out" if you plan to redistribute code from GXemul is to simply supply |
136 |
the source code. You should however check individual files for details.) |
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
<p><br> |
143 |
<a name="build"></a> |
144 |
<h3>How to compile/build the emulator:</h3> |
145 |
|
146 |
Uncompress the .tar.gz distribution file, and run |
147 |
<pre> |
148 |
$ <b>./configure</b> |
149 |
$ <b>make</b> |
150 |
</pre> |
151 |
|
152 |
<p> |
153 |
This should work on most Unix-like systems. If it doesn't, then please |
154 |
mail me a bug report. |
155 |
|
156 |
<p> |
157 |
(Note for Windows users: there is a possibility that some releases |
158 |
and/or snapshots will also work with Cygwin, but I can't promise that.) |
159 |
|
160 |
<p> |
161 |
The emulator's performance is highly dependent on both runtime settings |
162 |
and on compiler settings, so you might want to experiment with different |
163 |
CC and CFLAGS environment variable values. For example, on a modern PC, |
164 |
you could try the following: |
165 |
<p> |
166 |
<pre> |
167 |
$ <b>CFLAGS="-mcpu=pentium4 -O3" ./configure</b> |
168 |
$ <b>make</b> |
169 |
</pre> |
170 |
|
171 |
<p> |
172 |
Run <b>./configure --help</b> to get a list of configure options. (The |
173 |
possible options differ between different releases and snapshots.) |
174 |
|
175 |
<p> |
176 |
Once you have built GXemul, running it should be rather straight-forward. |
177 |
To exit the emulator, type CTRL-C to enter the |
178 |
single-step debugger, and then type <b>quit</b>. By typing CTRL-B instead, |
179 |
a CTRL-C is sent to the emulated program. |
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
<p><br> |
187 |
<a name="cpus"></a> |
188 |
<h3>Which CPU types does GXemul emulate?</h3> |
189 |
|
190 |
<h4>MIPS:</h4> |
191 |
|
192 |
Emulation of R4000, which is a 64-bit CPU, was my initial goal. Right |
193 |
now, R2000/R3000-like CPUs are also emulated (32-bit), and emulation of |
194 |
R1x000 (at least the parts that are similar to R4000) is beginning to work |
195 |
as expected. Code targeted for MIPS32 and MIPS64 also often work. |
196 |
|
197 |
<p> |
198 |
I have written an experimental dynamic binary translation subsystem. |
199 |
This gives higher total performance than interpreting one instruction at a |
200 |
time and executing it. (If you wish to enable bintrans, add <b>-b</b> to |
201 |
the command line, but keep in mind that it is still experimental.) |
202 |
|
203 |
|
204 |
|
205 |
<h4>URISC:</h4> |
206 |
|
207 |
I have implemented an <a href="http://en.wikipedia.org/wiki/URISC">URISC</a> |
208 |
emulation mode, just for fun. The only instruction available in an URISC |
209 |
machine is "reverse subtract and skip on borrow". (It is probably not |
210 |
worth trying to do bintrans with URISC, because any reasonable URISC |
211 |
program relies on self-modifying code, which is bad for bintrans |
212 |
performance.) |
213 |
|
214 |
|
215 |
|
216 |
|
217 |
<h4>Other CPU types:</h4> |
218 |
|
219 |
There is some code for 64-bit (and 32-bit) POWER/PowerPC emulation too, |
220 |
but it only works for "Hello World" and similarly trivial programs. (There |
221 |
are some other CPU modes too, but they are working even less.) |
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
<p><br> |
228 |
<a name="accuracy"></a> |
229 |
<h3>Emulation accuracy:</h3> |
230 |
|
231 |
GXemul is an instruction-level simulator; things that would happen in |
232 |
several steps within a real CPU are not taken into account (eg. pipe-line |
233 |
stages or out-of-order execution). Still, instruction-level accuracy seems |
234 |
to be enough to be able to run complete guest operating systems inside the |
235 |
emulator. |
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
<p><br> |
242 |
<a name="emulmodes"></a> |
243 |
<h3>Which machines does GXemul emulate?</h3> |
244 |
|
245 |
A few different machine types are emulated. The machine types that are |
246 |
emulated best at the moment are: |
247 |
|
248 |
<p> |
249 |
<ul> |
250 |
<li><b>DECstation 5000/200</b> ("pmax") |
251 |
<br>(Serial controller (including keyboard and mouse), ethernet, |
252 |
SCSI, and graphical framebuffers.) |
253 |
<p> |
254 |
<li><b>Acer Pica-61</b> (an ARC machine) |
255 |
<br>(Serial controller, "VGA" text console, and SCSI.) |
256 |
<p> |
257 |
<li><b>NEC MobilePro 770, 780, 800, and 880</b> (HPCmips machines) |
258 |
<br>(Framebuffer, keyboard, and a PCMCIA IDE controller.) |
259 |
</ul> |
260 |
|
261 |
<p> |
262 |
There is code in GXemul for emulation of many other machine types; |
263 |
the degree to which these work range from "almost" being able to run |
264 |
a complete OS, to almost completely unsupported (perhaps just enough |
265 |
support to output a few boot messages via serial console). |
266 |
|
267 |
<p> |
268 |
In addition to specific machine types, a "test-machine" can be emulated. |
269 |
A test-machine consists of one or more CPUs and a few experimental |
270 |
devices such as: |
271 |
|
272 |
<p> |
273 |
<ul> |
274 |
<li>a console I/O device (putchar() and getchar()...) |
275 |
<li>an inter-processor communication device, for SMP experiments |
276 |
<li>a very simple linear framebuffer device (for graphics output) |
277 |
</ul> |
278 |
|
279 |
<p> |
280 |
This mode is useful if you wish to run experimental code, but do not |
281 |
wish to target any specific real-world machine type, for example for |
282 |
educational purposes. |
283 |
|
284 |
<p> |
285 |
You can read more about these experimental devices |
286 |
<a href="experiments.html#expdevices">here</a>. |
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
<p><br> |
295 |
<a name="guestos"></a> |
296 |
<h3>Which guest OSes are possible to run?</h3> |
297 |
|
298 |
This table sums up the guest OSes that run well enough to be considered |
299 |
working in the emulator. They can boot from a harddisk image and be |
300 |
interacted with similar to a real machine: |
301 |
|
302 |
<p><br> |
303 |
<center> |
304 |
<table border="0"> |
305 |
<tr><td> |
306 |
<table border="0"> |
307 |
<tr><td align="center"> |
308 |
<table border="0"> |
309 |
<tr> |
310 |
<td valign="top"><b><u>Guest OS:</u></b></td> |
311 |
<td width="15"> </td> |
312 |
<td valign="top"><b><u>Emulation mode:</u></b></td> |
313 |
<td width="35"> </td> |
314 |
<td valign="top"><b><u>Guest OS:</u></b></td> |
315 |
<td width="15"> </td> |
316 |
<td valign="top"><b><u>Emulation mode:</u></b></td> |
317 |
</tr> |
318 |
|
319 |
<tr> |
320 |
<td height="1"></td> |
321 |
</tr> |
322 |
|
323 |
<tr> |
324 |
<td valign="top"><a href="http://www.netbsd.org/Ports/pmax/">NetBSD/pmax</a></td> |
325 |
<td></td> |
326 |
<td valign="top">DECstation</td> |
327 |
<td></td> |
328 |
<td valign="top"><a href="http://www.netbsd.org/Ports/arc/">NetBSD/arc</a></td> |
329 |
<td></td> |
330 |
<td valign="top">ARC (Acer Pica)</td> |
331 |
</tr> |
332 |
|
333 |
<tr> |
334 |
<td valign="top"><a href="http://www.openbsd.org/pmax.html">OpenBSD/pmax</a></td> |
335 |
<td></td> |
336 |
<td valign="top">DECstation</td> |
337 |
<td></td> |
338 |
<td valign="top"><a href="http://www.openbsd.org/arc.html">OpenBSD/arc</a></td> |
339 |
<td></td> |
340 |
<td valign="top">ARC (Acer Pica)</td> |
341 |
</tr> |
342 |
|
343 |
<tr> |
344 |
<td valign="top">Ultrix/RISC</td> |
345 |
<td></td> |
346 |
<td valign="top">DECstation</td> |
347 |
<td></td> |
348 |
<td valign="top"><a href="http://www.cs.berkeley.edu/projects/sprite/retrospective.html">Sprite</a></td> |
349 |
<td></td> |
350 |
<td valign="top">DECstation</td> |
351 |
</tr> |
352 |
|
353 |
<tr> |
354 |
<td valign="top">Redhat Linux<super>*</super></td> |
355 |
<td></td> |
356 |
<td valign="top">DECstation</td> |
357 |
<td></td> |
358 |
<td valign="top"><a href="http://www.debian.org/">Debian GNU/Linux</a><super>*</super></td> |
359 |
<td></td> |
360 |
<td valign="top">DECstation</td> |
361 |
</tr> |
362 |
|
363 |
<tr> |
364 |
<td valign="top"><a href="http://www.netbsd.org/Ports/hpcmips/">NetBSD/hpcmips</a></td> |
365 |
<td></td> |
366 |
<td valign="top">NEC MobilePro</td> |
367 |
</tr> |
368 |
</table> |
369 |
</td></tr> |
370 |
|
371 |
<tr><td height="15"> </td></tr> |
372 |
|
373 |
<tr><td> |
374 |
<center> |
375 |
<table border="0"> |
376 |
<tr> |
377 |
<td width=160 align=center><a href="netbsd-pmax-20040630.png"><img src="netbsd-pmax-20040630_small.png"></a></td> |
378 |
<td width=160 align=center><a href="openbsd-pmax-20040710.png"><img src="openbsd-pmax-20040710_small.png"></a></td> |
379 |
<td width=160 align=center><a href="ultrix4.5-20040706.png"><img src="ultrix4.5-20040706_small.gif"></a></td> |
380 |
</tr> |
381 |
<tr> |
382 |
<td align=center>NetBSD/pmax 1.6.2</td> |
383 |
<td align=center>OpenBSD/pmax 2.8</td> |
384 |
<td align=center>Ultrix 4.5</td> |
385 |
</tr> |
386 |
<tr> |
387 |
<td height=10> </td> |
388 |
</tr> |
389 |
<tr> |
390 |
<td width=160 align=center><a href="20041024-netbsd-arc-installed.gif"><img src="20041024-netbsd-arc-installed_small.gif"></a></td> |
391 |
<td width=160 align=center><a href="20041024-openbsd-arc-installed.gif"><img src="20041024-openbsd-arc-installed_small.gif"></a></td> |
392 |
<td width=160 align=center><a href="sprite-20040711.png"><img src="sprite-20040711_small.png"></a></td> |
393 |
</tr> |
394 |
<tr> |
395 |
<td align=center>NetBSD/arc 1.6.2</td> |
396 |
<td align=center>OpenBSD/arc 2.3</td> |
397 |
<td align=center>Sprite</td> |
398 |
</tr> |
399 |
<tr> |
400 |
<td height=10> </td> |
401 |
</tr> |
402 |
<tr> |
403 |
<td width=160 align=center><a href="20041129-redhat_mips.png"><img src="20041129-redhat_mips_small.png"></a></td> |
404 |
<td width=160 align=center><a href="20041213-debian_4.png"><img src="20041213-debian_4_small.gif"></a></td> |
405 |
<td width=160 align=center><a href="20050331-netbsd-hpcmips.png"><img src="20050331-netbsd-hpcmips_small.png"></a></td> |
406 |
</tr> |
407 |
<tr> |
408 |
<td align=center>Redhat Linux<super>*</super></td> |
409 |
<td align=center>Debian GNU/Linux<super>*</super></td> |
410 |
<td align=center>NetBSD/hpcmips</td> |
411 |
</tr> |
412 |
</table> |
413 |
</center> |
414 |
</td></tr> |
415 |
</table> |
416 |
</td></tr> |
417 |
</table> |
418 |
</center> |
419 |
|
420 |
<p><br> |
421 |
|
422 |
(<super>*</super> Although Linux runs under DECstation emulation, the |
423 |
default kernel in Debian GNU/Linux does not support keyboards on the 5000/200 |
424 |
(the specific DECstation model being emulated), so when the login prompt |
425 |
is reached you cannot interact with the system. |
426 |
Kaj-Michael Lang has compiled and made available a newer kernel from the |
427 |
current mips-linux development tree. You can find it here: |
428 |
<a href="http://home.tal.org/~milang/o2/kernels/">http://home.tal.org/~milang/o2/kernels</a>/<a href="http://home.tal.org/~milang/o2/kernels/vmlinux-2.4.29-rc2-r3k-mipsel-decstation">vmlinux-2.4.29-rc2-r3k-mipsel-decstation</a> |
429 |
This newer kernel supports keyboard input, but it does not have Debian's |
430 |
ethernet patches, so you will not be able to use keyboard/framebuffer |
431 |
<i>and</i> networking at the same time.) |
432 |
|
433 |
|
434 |
<p> |
435 |
It is non-trivial to get a specific operating system or OS kernel to |
436 |
run in the emulator, so don't expect the list above to grow too quickly. |
437 |
|
438 |
<p> |
439 |
There is no guarantee that anything specific will run in the emulator, but |
440 |
NetBSD is a good starting point for someone who wants to experiment. |
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
</p> |
447 |
|
448 |
</body> |
449 |
</html> |