/[gxemul]/trunk/doc/intro.html
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/doc/intro.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC
# Line 1  Line 1 
1  <html>  <html><head><title>Gavare's eXperimental Emulator:&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b>Gavare's eXperimental Emulator:&nbsp;&nbsp;&nbsp;</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.40 2005/04/27 15:22:17 debug Exp $  $Id: intro.html,v 1.64 2005/10/07 22:45:33 debug Exp $
14    
15  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.
16    
# Line 52  SUCH DAMAGE. Line 49  SUCH DAMAGE.
49    <li><a href="#overview">Overview</a>    <li><a href="#overview">Overview</a>
50    <li><a href="#free">Is GXemul Free software?</a>    <li><a href="#free">Is GXemul Free software?</a>
51    <li><a href="#build">How to compile/build the emulator</a>    <li><a href="#build">How to compile/build the emulator</a>
52      <li><a href="#run">How to run the emulator</a>
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    
# Line 66  SUCH DAMAGE. Line 64  SUCH DAMAGE.
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  It is important to keep in mind that devices and CPUs are not simulated  architectures are also partially emulated.
 with 100% accuracy. They are only "faked" well enough to make operating  
 systems (eg NetBSD) run. Still, the emulator could be of interest for  
 academic research and experiments, such as when learning how to write  
 operating system code.  
74    
75  <p>  <p>Devices and CPUs are not simulated with 100% accuracy. They are only
76  The emulator is written in C, does not depend on external libraries (except  ``faked'' well enough to make operating systems (e.g. NetBSD) run without
77  X11, but that is optional), and should compile and run on most Unix-like  complaining too much. Still, the emulator could be of interest for
78  systems. If it doesn't, then that is a bug.  academic research and experiments, such as when learning how to write
79  (You do not need any MIPS compiler toolchain to build or use GXemul.  operating system code.
 If you need to compile MIPS binaries from sources, then of course you need  
 such a toolchain, but that is completely separate from GXemul. There  
 is a <a href="technical.html#regtest">regression testing</a> framework,  
 which requires that a GNU CC for mips64-unknown-elf or similar is available.  
 For simply building and using the emulator, it is not required.)  
80    
81  <p>  <p>The emulator is written in C, does not depend on external libraries
82  The emulator contains code which tries to emulate the workings of CPUs and  (except X11, but that is optional), and should compile and run on most
83  surrounding hardware found in real machines, but it does not contain any  Unix-like systems. If it doesn't, then that is a bug.
84  ROM code. You will need some form of program (in binary form) to run in  
85  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
86    and surrounding hardware found in real machines, but it does not contain
87    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
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).
95  ECOFF, SREC, raw binaries).  
96    <p>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
98    image. (This works for example with DECstation emulation, or when booting
99    from ISO9660 CDROM images.)
100    
101    
102    
103    
104    
105    
# Line 111  ECOFF, SREC, raw binaries). Line 109  ECOFF, SREC, raw binaries).
109  <a name="free"></a>  <a name="free"></a>
110  <h3>Is GXemul Free software?</h3>  <h3>Is GXemul Free software?</h3>
111    
112  Yes. I have released GXemul under a Free license.  Yes. I have released GXemul under a Free license. The code in GXemul is
113  (For a definitions of the four freedoms associated with Free software,  Copyrighted software, it is <i>not</i> public domain. (If this is
114  please read <a href="http://www.gnu.org/philosophy/free-sw.html">  confusing to you, you might want to read up on the definitions of the
115  http://www.gnu.org/philosophy/free-sw.html</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>.)
117    
118    <p>The code I have written is released under a 3-clause BSD-style license
119    (or "revised BSD-style" if one wants to use <a
120    href="http://www.gnu.org/philosophy/bsd.html">GNU jargon</a>). Apart from
121    the code I have written, some files are copied from other sources such as
122    NetBSD, for example header files containing symbolic names of bitfields in
123    device registers. They are also covered by similar licenses, but with some
124    additional clauses. The main point, however, is that the licenses require
125    that the original Copyright and license terms are included when you make a
126    copy or modification.
127    
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 code in GXemul is Copyrighted software, it is <i>not</i> public  
 domain or anything like that.  
   
 <p>  
 The code I have written is released under a 3-clause BSD-style license  
 (or "revised BSD-style" if one wants to use  
 <a href="http://www.gnu.org/philosophy/bsd.html">GNU jargon</a>).  
 Apart from the code I have written, some files are copied from other sources  
 such as NetBSD, for example header files containing symbolic names of  
 bitfields in device registers. They are also covered by similar licenses,  
 but with some additional clauses. If you plan to redistribute GXemul  
 (for example as a binary package), or reuse code from GXemul,  
 then you should check those files for their license terms.  
   
 <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    
# Line 151  Uncompress the .tar.gz distribution file Line 154  Uncompress the .tar.gz distribution file
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 a modern PC,
163  you could try the following:  you could try the following:
164  <p>  <p><pre>
165  <pre>          $ <b>CFLAGS="-mcpu=pentium4 -O3" ./configure</b>
166          $ <b>CFLAGS="-mcpu=pentium4 -O3" ./configure</b>          $ <b>make</b>
         $ <b>make</b>  
167  </pre>  </pre>
168    
169    
170    
171    
172    
173    
174    
175    <p><br>
176    <a name="run"></a>
177    <h3>How to run the emulator:</h3>
178    
179    Once you have built GXemul, running it should be rather straight-forward.
180    Running <tt><b>gxemul</b></tt> without arguments (or with the
181    <b><tt>-h</tt></b> or <b><tt>-H</tt></b> command line options) will
182    display a help message.
183    
184  <p>  <p>
185  Run <b>./configure --help</b> to get a list of configure options. (The  To get some ideas about what is possible to run in the emulator, please
186  possible options differ between different releases and snapshots.)  read the section about <a href="guestoses.html">installing "guest"
187    operating systems</a>. If you are interested in using the emulator to
188    develop code on your own, then you should also read the section about
189    <a href="experiments.html#hello">Hello World</a>.
190    
191  <p>  <p>
 Once you have built GXemul, running it should be rather straight-forward.  
192  To exit the emulator, type CTRL-C to enter the  To exit the emulator, type CTRL-C to enter the
193  single-step debugger, and then type <b>quit</b>.  single-step debugger, and then type <tt><b>quit</b></tt>.
194    
195  <p>  <p>
196  If you are starting an emulation by entering settings directly on the  If you are starting an emulation by entering settings directly on the
197  command line, and you are not using the <b>-x</b> option, then all  command line, and you are not using the <tt><b>-x</b></tt> option, then all
198  terminal input and output will go to the main controlling terminal.  terminal input and output will go to the main controlling terminal.
199  CTRL-C is used to break into the debugger, so in order to send CTRL-C to  CTRL-C is used to break into the debugger, so in order to send CTRL-C to
200  the running (emulated) program, you may use CTRL-B.  the running (emulated) program, you may use CTRL-B.
201    (This should be a reasonable compromise to allow the emulator to be usable
202    even on systems without X Windows.)
203    
204  <p>  <p>
205  (This is an ugly hack; there is no way to send an actual CTRL-B to the  There is no way to send an actual CTRL-B to the emulated program, when
206  emulated program, when typing in the main controlling terminal window.  typing in the main controlling terminal window. The solution is to either
207  The solution is to either use configuration files, or use <b>-x</b>. Both  use <a href="configfiles.html">configuration files</a>, or use
208  these solutions cause new xterms to be opened for each emulated serial  <tt><b>-x</b></tt>. Both these solutions cause new xterms to be opened for
209  port. CTRL-B and CTRL-C both have their original meaning in those  each emulated serial port that is written to. CTRL-B and CTRL-C both have
210  xterm windows.)  their original meaning in those xterm windows.
   
211    
212    
213    
# Line 205  xterm windows.) Line 219  xterm windows.)
219    
220  <h4>MIPS:</h4>  <h4>MIPS:</h4>
221    
222  Emulation of R4000, which is a 64-bit CPU, was my initial goal. Right  Emulation of R4000, which is a 64-bit CPU, was my initial goal.
223  now, R2000/R3000-like CPUs are also emulated (32-bit), and emulation of  R2000/R3000-like CPUs (32-bit), R1x000, and generic MIPS32/MIPS64-style
224  R1x000 (at least the parts that are similar to R4000) is beginning to work  CPUs are also emulated, and are hopefully almost as stable as the R4000
225  as expected. Code targeted for MIPS32 and MIPS64 also often work.  emulation.
226    
227  <p>  <p>I have written an experimental dynamic binary translation subsystem.
 I have written an experimental dynamic binary translation subsystem.  
228  This gives higher total performance than interpreting one instruction at a  This gives higher total performance than interpreting one instruction at a
229  time and executing it. (If you wish to enable bintrans, add <b>-b</b> to  time and executing it. (If you wish to disable bintrans, add <b>-B</b> to
230  the command line, but keep in mind that it is still experimental.)  the command line.)
   
   
   
 <h4>URISC:</h4>  
   
 I have implemented an <a href="http://en.wikipedia.org/wiki/URISC">URISC</a>  
 emulation mode, just for fun. The only instruction available in an URISC  
 machine is "reverse subtract and skip on borrow". (It is probably not  
 worth trying to do bintrans with URISC, because any reasonable URISC  
 program relies on self-modifying code, which is bad for bintrans  
 performance.)  
   
231    
232    <h4>ARM:</h4>
233    
234    The ARM CPU emulation is good enough to run NetBSD/cats and OpenBSD/cats
235    (almost bugfree :-), but it is not as tested or fine-tuned as the MIPS
236    emulation.
237    
238  <h4>Other CPU types:</h4>  <h4>Other CPU types:</h4>
239    
240  There is some code for 64-bit (and 32-bit) POWER/PowerPC emulation too,  Some other CPU architectures can also be partially emulated. These are not
241  but it only works for "Hello World" and similarly trivial programs. (There  working well enough yet to run guest operating systems.
242  are some other CPU modes too, but they are working even less.)  
243    
244    
245    
# Line 244  are some other CPU modes too, but they a Line 249  are some other CPU modes too, but they a
249  <a name="accuracy"></a>  <a name="accuracy"></a>
250  <h3>Emulation accuracy:</h3>  <h3>Emulation accuracy:</h3>
251    
252  GXemul is an instruction-level simulator; things that would happen in  GXemul is an instruction-level emulator; things that would happen in
253  several steps within a real CPU are not taken into account (eg. pipe-line  several steps within a real CPU are not taken into account (eg. pipe-line
254  stages or out-of-order execution). Still, instruction-level accuracy seems  stalls or out-of-order execution). Still, instruction-level accuracy seems
255  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
256  emulator.  emulator.
257    
258    <p>Caches are by default not emulated. In some cases, the existance of
259    caches is "faked" to let operating systems think that they are there.
260    (There is some old code for R2000/R3000 caches, but it has probably
261    suffered from bitrot by now.)
262    
263    <p>The emulator is <i>not</i> timing-accurate. It can be run in a
264    "deterministic" mode, <tt><b>-D</b></tt>. The meaning of deterministic is
265    simply that running two emulations with the same settings will result in
266    identical runs. Obviously, this requires that no user interaction is
267    taking place, and that clock speeds are fixed with the <tt><b>-I</b></tt>
268    option. (Deterministic in this case does <i>not</i> mean that the
269    emulation will be identical to some actual real-world machine.)
270    
271    
272    
273    
# Line 263  are emulated well enough to run at least Line 281  are emulated well enough to run at least
281    
282  <p>  <p>
283  <ul>  <ul>
284    <li><b>DECstation 5000/200</b>&nbsp;&nbsp;("3max")    <li><b><u>MIPS</u></b>
285      <ul>
286        <li><b>DECstation 5000/200</b>&nbsp;&nbsp;("3max")
287          <br>Serial controller (including keyboard and mouse), ethernet,          <br>Serial controller (including keyboard and mouse), ethernet,
288          SCSI, and graphical framebuffers.          SCSI, and graphical framebuffers.
289    <p>      <p>
290    <li><b>Acer Pica-61</b>&nbsp;&nbsp;(an ARC machine)      <li><b>Acer Pica-61</b>&nbsp;&nbsp;(an ARC machine)
291          <br>Serial controller, "VGA" text console, and SCSI.          <br>Serial controller, "VGA" text console, and SCSI.
292    <p>      <p>
293    <li><b>NEC MobilePro 770, 780, 800, and 880</b>&nbsp;&nbsp;(HPCmips machines)      <li><b>NEC MobilePro 770, 780, 800, and 880</b>&nbsp;&nbsp;(HPCmips machines)
294          <br>Framebuffer, keyboard, and a PCMCIA IDE controller.          <br>Framebuffer, keyboard, and a PCMCIA IDE controller.
295    <p>      <p>
296    <li><b>Cobalt</b>      <li><b>Cobalt</b>
297          <br>Serial controller and PCI IDE.          <br>Serial controller and PCI IDE.
298        <p>
299        <li><b>Malta (evbmips)</b>
300            <br>Serial controller and PCI IDE.
301        <p>
302        <li><b>SGI O2 ("IP32")</b>
303            <br>Serial controller and ethernet.&nbsp;&nbsp;<small>(Enough for
304            root-on-nfs, but not for disk boot.)</small>
305      </ul>
306      <p>
307      <li><b><u>ARM</u></b>
308      <ul>
309        <li><b>CATS</b>
310            <br>VGA and PCI IDE.
311      </ul>
312  </ul>  </ul>
313    
314  <p>  <p>There is code in GXemul for emulation of many other machine types; the
315  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
316  the degree to which these work range from "almost" being able to run  OS, to almost completely unsupported (perhaps just enough support to
317  a complete OS, to almost completely unsupported (perhaps just enough  output a few boot messages via serial console).
318  support to output a few boot messages via serial console).  
319    <p>In addition to emulating real machines, there is also a "test-machine".
320  <p>  A test-machine consists of one or more CPUs and a few experimental devices
321  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:  
322    
323  <p>  <p>
324  <ul>  <ul>
325    <li>a console I/O device (putchar() and getchar()...)    <li>a console I/O device (putchar() and getchar()...)
326    <li>an inter-processor communication device, for SMP experiments    <li>an inter-processor communication device, for SMP experiments
327    <li>a very simple linear framebuffer device (for graphics output)    <li>a very simple linear framebuffer device (for graphics output)
328      <li>a simple SCSI disk controller
329      <li>a simple ethernet controller
330  </ul>  </ul>
331    
332  <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  
333  wish to target any specific real-world machine type, for example for  wish to target any specific real-world machine type, for example for
334  educational purposes.  educational purposes.
335    
336  <p>  <p>You can read more about these experimental devices <a
337  You can read more about these experimental devices  href="experiments.html#expdevices">here</a>.
 <a href="experiments.html#expdevices">here</a>.  
338    
339    
340    
# Line 312  You can read more about these experiment Line 344  You can read more about these experiment
344    
345  <p><br>  <p><br>
346  <a name="guestos"></a>  <a name="guestos"></a>
347  <h3>Which guest OSes are possible to run?</h3>  <h3>Which guest OSes are possible to run in GXemul?</h3>
348    
349  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
350  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
# Line 322  interacted with similar to a real machin Line 354  interacted with similar to a real machin
354  <center><table border="0">  <center><table border="0">
355          <tr>          <tr>
356            <td width="10"></td>            <td width="10"></td>
357            <td align="center"><a href="netbsd-pmax-20040630.png"><img src="netbsd-pmax-20040630_small.png"></a></td>            <td align="center"><a href="20050317-example.png"><img src="20050317-example_small.png"></a></td>
358            <td width="15"></td>            <td width="15"></td>
359            <td><a href="http://www.netbsd.org/Ports/pmax/">NetBSD/pmax</a>            <td><a href="http://www.netbsd.org/Ports/pmax/">NetBSD/pmax</a>
360                  <br>DECstation 5000/200</td>                  <br>DECstation 5000/200</td>
# Line 393  interacted with similar to a real machin Line 425  interacted with similar to a real machin
425                  <br>Cobalt</td>                  <br>Cobalt</td>
426          </tr>          </tr>
427    
428            <tr><td height="10"></td></tr>
429    
430            <tr>
431              <td></td>
432              <td align="center"><a href="20050626-netbsd-sgimips-netboot.png"><img src="20050626-netbsd-sgimips-netboot_small.png"></a></td>
433              <td></td>
434              <td><a href="http://www.netbsd.org/Ports/sgimips/">NetBSD/sgimips</a>
435                    <br>SGI O2 ("IP32")</td>
436              <td></td>
437              <td align="center"><a href="20050622-netbsd-evbmips-malta.png"><img src="20050622-netbsd-evbmips-malta_small.png"></a></td>
438              <td></td>
439              <td><a href="http://www.netbsd.org/Ports/evbmips/">NetBSD/evbmips</a>
440                    <br>5Kc (and 4Kc) Malta<br>evaluation boards</td>
441              <td></td>
442            </tr>
443    
444            <tr><td height="10"></td></tr>
445    
446            <tr>
447              <td></td>
448              <td align="center"><a href="20051007-netbsd-cats-installed.png"><img src="20051007-netbsd-cats-installed_small.png"></a></td>
449              <td></td>
450              <td><a href="http://www.netbsd.org/Ports/cats/">NetBSD/cats</a>
451                    <br>CATS</td>
452              <td></td>
453              <td align="center"><a href="20051007-openbsd-cats-installed.png"><img src="20051007-openbsd-cats-installed_small.png"></a></td>
454              <td></td>
455              <td><a href="http://www.openbsd.org/cats.html">OpenBSD/cats</a>
456                    <br>CATS</td>
457              <td></td>
458            </tr>
459    
460  </table></center>  </table></center>
461    
462    

Legend:
Removed from v.4  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26