1 |
<html><head><title>GXemul documentation: Technical details</title> |
<html><head><title>Gavare's eXperimental Emulator: Technical details</title> |
2 |
<meta name="robots" content="noarchive,nofollow,noindex"></head> |
<meta name="robots" content="noarchive,nofollow,noindex"></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>Technical details</b> |
<font color="#000000" size="6"><b>Technical details</b> |
9 |
</font></td></tr></table></td></tr></table><p> |
</font></td></tr></table></td></tr></table><p> |
10 |
|
|
11 |
<!-- |
<!-- |
12 |
|
|
13 |
$Id: technical.html,v 1.53 2005/06/27 17:31:50 debug Exp $ |
$Id: technical.html,v 1.63 2005/10/07 15:10:00 debug Exp $ |
14 |
|
|
15 |
Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
16 |
|
|
40 |
--> |
--> |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
<a href="./">Back to the index</a> |
<a href="./">Back to the index</a> |
45 |
|
|
46 |
<p><br> |
<p><br> |
53 |
<li><a href="#speed">Speed and emulation modes</a> |
<li><a href="#speed">Speed and emulation modes</a> |
54 |
<li><a href="#net">Networking</a> |
<li><a href="#net">Networking</a> |
55 |
<li><a href="#devices">Emulation of hardware devices</a> |
<li><a href="#devices">Emulation of hardware devices</a> |
|
<li><a href="#regtest">Regression tests</a> |
|
56 |
</ul> |
</ul> |
57 |
|
|
58 |
|
|
64 |
<a name="speed"></a> |
<a name="speed"></a> |
65 |
<h3>Speed and emulation modes</h3> |
<h3>Speed and emulation modes</h3> |
66 |
|
|
67 |
So, how fast is GXemul? There is no good answer to this. There is |
So, how fast is GXemul? There is no short answer to this. There is |
68 |
especially no answer to the question <b>What is the slowdown factor?</b>, |
especially no answer to the question <b>What is the slowdown factor?</b>, |
69 |
because the host architecture and emulated architecture can usually not be |
because the host architecture and emulated architecture can usually not be |
70 |
compared just like that. |
compared just like that. |
89 |
install NetBSD?", or "How long does it take to compile XYZ inside NetBSD |
install NetBSD?", or "How long does it take to compile XYZ inside NetBSD |
90 |
in the emulator?". |
in the emulator?". |
91 |
|
|
92 |
|
<p>So, how fast is it? :-) Answer: it varies. |
93 |
|
|
94 |
<p>The emulation technique used varies depending on which processor type |
<p>The emulation technique used varies depending on which processor type |
95 |
is being emulated. (One of my main goals with GXemul is to experiment with |
is being emulated. (One of my main goals with GXemul is to experiment with |
96 |
different kinds of emulation, so these might change in the future.) |
different kinds of emulation, so these might change in the future.) |
97 |
|
|
98 |
<ul> |
<ul> |
99 |
<li><b>MIPS</b><br> |
<li><b>MIPS:</b><br> |
100 |
There are two emulation modes. The most important one is an |
There are two emulation modes. The most important one is an |
101 |
implementation of a <i>dynamic binary translator</i>. |
implementation of a <i>dynamic binary translator</i>. |
102 |
(Compared to real binary translators, though, GXemul's bintrans |
(Compared to real binary translators, though, GXemul's bintrans |
107 |
works. It can be forcefully used by using the <tt>-B</tt> command |
works. It can be forcefully used by using the <tt>-B</tt> command |
108 |
line option.) |
line option.) |
109 |
<p> |
<p> |
110 |
<li><b>ARM</b><br> |
<li><b>All other modes:</b><br> |
111 |
This mode does not really work yet, but will use |
These use a kind of dynamic translation system. (This system does |
112 |
dynamic translation, but not binary translation. Stay tuned. :-) |
not use host-specific backends, so it is not "recompilation" or |
113 |
<p> |
anything like that.) Speed is slower than real binary translation, |
114 |
<li><b>URISC</b><br> |
but faster than traditional interpretation, and with some tricks |
115 |
Simple interpretation, one instruction at a time. There is probably |
it will hopefully still give reasonable speed. ARM emulation uses |
116 |
no other way to emulate URISC, because it relies too heavily |
this kind of translation, for example. |
|
on self-modifying code. |
|
|
<p> |
|
|
<li><b>POWER/PowerPC</b><br> |
|
|
This emulation mode is very much unfinished, but still enabled by |
|
|
default. So far it uses plain interpretation, where an instruction |
|
|
is read from emulated memory, and interpreted one at a time. |
|
|
Slow. Not very interesting. |
|
|
<p> |
|
|
<li><b>x86</b><br> |
|
|
Although too unstable and non-working to be enabled by default, |
|
|
there is some code for emulating x86 machines. It simply reads |
|
|
one instruction at a time from emulated memory, and executes it. |
|
|
This is as slow as it gets. Not very interesting. |
|
117 |
</ul> |
</ul> |
118 |
|
|
119 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
|
|
|
124 |
<p><br> |
<p><br> |
125 |
<a name="net"></a> |
<a name="net"></a> |
126 |
<h3>Networking</h3> |
<h3>Networking</h3> |
331 |
<a name="devices"></a> |
<a name="devices"></a> |
332 |
<h3>Emulation of hardware devices</h3> |
<h3>Emulation of hardware devices</h3> |
333 |
|
|
334 |
Each file in the <tt>device/</tt> directory is responsible for one |
Each file in the <tt>src/device/</tt> directory is responsible for one |
335 |
hardware device. These are used from <tt>src/machine.c</tt>, when |
hardware device. These are used from <tt>src/machine.c</tt>, when |
336 |
initializing which hardware a particular machine model will be using, or |
initializing which hardware a particular machine model will be using, or |
337 |
when adding devices to a machine using the <tt>device()</tt> command in |
when adding devices to a machine using the <tt>device()</tt> command in |
462 |
|
|
463 |
|
|
464 |
|
|
|
<p><br> |
|
|
<a name="regtest"></a> |
|
|
<h3>Regression tests</h3> |
|
|
|
|
|
In order to make sure that the emulator actually works like it is supposed |
|
|
to, it must be tested. For this purpose, there is a simple regression |
|
|
testing framework in the <tt>tests/</tt> directory. |
|
|
|
|
|
<p> |
|
|
<i>NOTE: The regression testing framework is basically just a skeleton so far. |
|
|
Regression tests are very good to have. However, the fact that complete |
|
|
operating systems can run in the emulator indicate that the emulation is |
|
|
probably not too incorrect. This makes it less of a priority to write |
|
|
regression tests.</i> |
|
|
|
|
|
<p> |
|
|
To run all the regression tests, type <tt>make regtest</tt>. Each assembly |
|
|
language file matching the pattern <tt>test_*.S</tt> will be compiled and |
|
|
linked into a 64-bit MIPS ELF (using a gcc cross compiler), and run in the |
|
|
emulator. If everything goes well, you should see something like this: |
|
|
|
|
|
<pre> |
|
|
$ make regtest |
|
|
cd tests; make run_tests; cd .. |
|
|
gcc33 -Wall -fomit-frame-pointer -fmove-all-movables -fpeephole -O2 |
|
|
-mcpu=ev5 -I/usr/X11R6/include -lm -L/usr/X11R6/lib -lX11 do_tests.c |
|
|
-o do_tests |
|
|
do_tests.c: In function `main': |
|
|
do_tests.c:173: warning: unused variable `s' |
|
|
/var/tmp//ccFOupvD.o: In function `do_tests': |
|
|
/var/tmp//ccFOupvD.o(.text+0x3a8): warning: tmpnam() possibly used |
|
|
unsafely; consider using mkstemp() |
|
|
mips64-unknown-elf-gcc -g -O3 -fno-builtin -fschedule-insns -mips64 |
|
|
-mabi=64 test_common.c -c -o test_common.o |
|
|
./do_tests "mips64-unknown-elf-gcc -g -O3 -fno-builtin -fschedule-insns |
|
|
-mips64 -mabi=64" "mips64-unknown-elf-as -mabi=64 -mips64" |
|
|
"mips64-unknown-elf-ld -Ttext 0xa800000000030000 -e main |
|
|
--oformat=elf64-bigmips" "../gxemul" |
|
|
|
|
|
Starting tests: |
|
|
test_addu.S (-a) |
|
|
test_addu.S (-a -b) |
|
|
test_clo_clz.S (-a) |
|
|
test_clo_clz.S (-a -b) |
|
|
.. |
|
|
test_unaligned.S (-a) |
|
|
test_unaligned.S (-a -b) |
|
|
|
|
|
Done. (12 tests done) |
|
|
PASS: 12 |
|
|
FAIL: 0 |
|
|
|
|
|
---------------- |
|
|
|
|
|
All tests OK |
|
|
|
|
|
---------------- |
|
|
</pre> |
|
|
|
|
|
<p> |
|
|
Each test writes output to stdout, and there is a <tt>test_*.good</tt> for |
|
|
each <tt>.S</tt> file which contains the wanted output. If the actual |
|
|
output matches the <tt>.good</tt> file, then the test passes, otherwise it |
|
|
fails. |
|
|
|
|
|
<p> |
|
|
Read <tt>tests/README</tt> for more information. |
|
|
|
|
|
|
|
|
|
|
465 |
|
|
466 |
</body> |
</body> |
467 |
</html> |
</html> |