/[gxemul]/trunk/doc/technical.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/technical.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 8 by dpavlin, Mon Oct 8 16:18:19 2007 UTC
# Line 1  Line 1 
1  <html>  <html><head><title>GXemul documentation: Technical details</title>
2  <head><title>GXemul documentation: Technical details</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>
# Line 8  Line 7 
7  <b>GXemul documentation:</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b>GXemul documentation:</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
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>
 <!-- The first 10 lines are cut away by the homepage updating script.  -->  
   
10    
11  <!--  <!--
12    
13  $Id: technical.html,v 1.49 2005/04/16 00:29:45 debug Exp $  $Id: technical.html,v 1.51 2005/06/04 22:47:49 debug Exp $
14    
15  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.
16    
# Line 52  SUCH DAMAGE. Line 49  SUCH DAMAGE.
49  This page describes some of the internals of GXemul.  This page describes some of the internals of GXemul.
50    
51  <p>  <p>
52    <font color="#e00000"><b>NOTE: This page is probably not
53    very up-to-date by now.</b></font>
54    
55    <p>
56  <ul>  <ul>
57    <li><a href="#overview">Overview</a>    <li><a href="#overview">Overview</a>
58    <li><a href="#speed">Speed</a>    <li><a href="#speed">Speed</a>
# Line 128  code into machine code that can be execu Line 129  code into machine code that can be execu
129  on-the-fly. The translation itself obviously takes some time, but this is  on-the-fly. The translation itself obviously takes some time, but this is
130  usually made up for by the fact that the translated code chunks are  usually made up for by the fact that the translated code chunks are
131  executed multiple times.  executed multiple times.
132  To run the emulator with binary translation enabled, just add <b>-b</b>  To run the emulator with binary translation enabled, just add
133  to the command line.  <tt><b>-b</b></tt> to the command line.
134    
135  <p>  <p>
136  Only small pieces of MIPS machine code are translated, usually the size of  Only small pieces of MIPS machine code are translated, usually the size of
# Line 138  all translations are done directly from Line 139  all translations are done directly from
139    
140  <p>  <p>
141  The default bintrans cache size is 16 MB, but you can change this by adding  The default bintrans cache size is 16 MB, but you can change this by adding
142  -DDEFAULT_BINTRANS_SIZE_IN_MB=<i>xx</i> to your CFLAGS environment variable  <tt>-DDEFAULT_BINTRANS_SIZE_IN_MB=<i>xx</i></tt> to your CFLAGS environment
143  before running the configure script, or by using the bintrans_size()  variable before running the configure script, or by using the
144  configuration file option when running the emulator.  <tt>bintrans_size()</tt> configuration file option when running the emulator.
145    
146  <p>  <p>
147  By default, an emulated OS running under DECstation emulation which listens to  By default, an emulated OS running under DECstation emulation which listens to
# Line 149  host's clock. That is, if the emulated O Line 150  host's clock. That is, if the emulated O
150  second, it will get approximately 100 interrupts per real second.  second, it will get approximately 100 interrupts per real second.
151    
152  <p>  <p>
153  There is however a -I option, which sets the number of emulated cycles per  There is however a <tt><b>-I</b></tt> option, which sets the number of
154  seconds to a fixed value. Let's say you wish to make the emulated OS think it  emulated cycles per seconds to a fixed value. Let's say you wish to make the
155  is running on a 40 MHz DECstation, and not a 7 MHz one, then you can add  emulated OS think it is running on a 40 MHz DECstation, and not a 7 MHz one,
156  -I 40000000 to the command line. This will not make the emulation faster, of  then you can add <tt><b>-I 40000000</b></tt> to the command line. This will not
157  course. It might even make it seem slower; for example, if NetBSD/pmax waits  make the emulation faster, of course. It might even make it seem slower; for
158  2 seconds for SCSI devices to settle during bootup, those 2 seconds will take  example, if NetBSD/pmax waits 2 seconds for SCSI devices to settle during
159  2*40000000 cycles (which will take more time than 2*7000000).  bootup, those 2 seconds will take 2*40000000 cycles (which will take more
160    time than 2*7000000).
161    
162  <p>  <p>
163  The -I option is also necessary if you want to run deterministic experiments,  The <b><tt>-I</tt></b> option is also necessary if you want to run
164  if a mc146818 device is present.  deterministic experiments, if a mc146818 (or similar) device is present.
165    
166  <p>  <p>
167  Some emulators make claims such as "x times slowdown," but in the case of  Some emulators make claims such as "x times slowdown," but in the case of
# Line 205  As far as I have understood it, there se Line 207  As far as I have understood it, there se
207                  connect from the emulated OS to the OS running on the                  connect from the emulated OS to the OS running on the
208                  host, as packets sent out on the host's NIC are not                  host, as packets sent out on the host's NIC are not
209                  received by itself. (?)                  received by itself. (?)
210              <li>All specific networking protocols will be handled by the
211                    physical network.
212          </ul>          </ul>
213    <p>    <p>
214    or    or
# Line 233  As far as I have understood it, there se Line 237  As far as I have understood it, there se
237          </ul>          </ul>
238  </ol>  </ol>
239    
240  Other emulators that I have heard of seem to use the first one, if they  <p>
241  support networking.  Some emulators/simulators use the first approach, while others use the
242    second. I think that SIMH and QEMU are examples of emulators using the
243    first and second approach, respectively.
244    
245  <p>  <p>
246  Since I have choosen the second kind of implementation, I have to write  Since I have choosen the second kind of implementation, I have to write
# Line 249  emulation (-E dec -e 3max): Line 255  emulation (-E dec -e 3max):
255          and converted to ARP responses. (This is used by the emulated OS          and converted to ARP responses. (This is used by the emulated OS
256          to find out the MAC address of the gateway.)          to find out the MAC address of the gateway.)
257    <li>ICMP echo requests (that is the kind of packet produced by the    <li>ICMP echo requests (that is the kind of packet produced by the
258          <b>ping</b> program) are interpreted and converted to ICMP echo          <b><tt>ping</tt></b> program) are interpreted and converted to ICMP echo
259          replies, <i>regardless of the IP address</i>. This means that          replies, <i>regardless of the IP address</i>. This means that
260          running ping from within the emulated OS will <i>always</i>          running ping from within the emulated OS will <i>always</i>
261          receive a response. The ping packets never leave the emulated          receive a response. The ping packets never leave the emulated
# Line 263  emulation (-E dec -e 3max): Line 269  emulation (-E dec -e 3max):
269          packets are handled (but more state is kept for each connection).          packets are handled (but more state is kept for each connection).
270          <font color="#ff0000">NOTE: Much of the TCP handling code is very          <font color="#ff0000">NOTE: Much of the TCP handling code is very
271          ugly and hardcoded.</font>          ugly and hardcoded.</font>
272    <!--
273    <li>RARP is not implemented yet. (I haven't needed it so far.)    <li>RARP is not implemented yet. (I haven't needed it so far.)
274    -->
275  </ul>  </ul>
276    
277    <p>
278  The gateway machine, which is the only "other" machine that the emulated  The gateway machine, which is the only "other" machine that the emulated
279  OS sees on its emulated network, works as a NAT-style firewall/gateway. It  OS sees on its emulated network, works as a NAT-style firewall/gateway. It
280  has a fixed IPv4 address of 10.0.0.254. An OS running in the emulator  usually has a fixed IPv4 address of <tt>10.0.0.254</tt>. An OS running in
281  can thus have any 10.x.x.x address; a typical choice would be 10.0.0.1.  the emulator would usually have an address of the form <tt>10.x.x.x</tt>;
282    a typical choice would be <tt>10.0.0.1</tt>.
283    
284  <p>  <p>
285  Inside emulated NetBSD or OpenBSD, running the following commands should  Inside emulated NetBSD/pmax or OpenBSD/pmax, running the following
286  configure the emulated NIC:  commands should configure the emulated NIC:
287  <pre>  <pre>
288          # <b>ifconfig le0 10.0.0.1</b>          # <b>ifconfig le0 10.0.0.1</b>
289          # <b>route add default 10.0.0.254</b>          # <b>route add default 10.0.0.254</b>
290          add net default: gateway 10.0.0.254          add net default: gateway 10.0.0.254
291  </pre>  </pre>
292    
293    <p>
294  If you want nameserver lookups to work, you need a valid /etc/resolv.conf  If you want nameserver lookups to work, you need a valid /etc/resolv.conf
295  as well:  as well:
296  <pre>  <pre>
297          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>
298  </pre>  </pre>
299  (But replace 129.16.1.3 with the actual real-world IP address of your  (But replace <tt>129.16.1.3</tt> with the actual real-world IP address of
300  nearest nameserver.)  your nearest nameserver.)
301    
302  <p>  <p>
303  Now, host lookups should work:  Now, host lookups should work:
304  <pre>  <pre>
# Line 309  Now, host lookups should work: Line 321  Now, host lookups should work:
321          uucp-gw-2.pa.dec.com    172799 IN       A       204.123.2.19          uucp-gw-2.pa.dec.com    172799 IN       A       204.123.2.19
322  </pre>  </pre>
323    
324  To transfer files via UDP, you can use the tftp program.  <p>
325    At this point, UDP and TCP should (mostly) work.
 <pre>  
         # <b>tftp 12.34.56.78</b>  
         tftp> <b>get filename</b>  
         Received XXXXXX bytes in X.X seconds  
         tftp> <b>quit</b>  
         #  
 </pre>  
   
 or, to do it non-interactively (with ugly output):  
   
 <pre>  
         # <b>echo get filename | tftp 12.34.56.78</b>  
         tftp> Received XXXXXX bytes in X.X seconds  
         tftp> #  
 </pre>  
326    
327  This, of course, requires that you have put the file <i>filename</i> in  <p>
328  the root directory of the tftp server (12.34.56.78).  Here is an example of how to configure a server machine and an emulated
329    client machine for sharing files via NFS:
330    
331  <p>  <p>
332  It is also possible to run NFS via UDP. This is very useful if you want to  (This is very useful if you want to share entire directory trees
333  share entire directory trees between the emulated environment and another  between the emulated environment and another machine. These instruction
334  machine. These instruction will work for FreeBSD, if you are running  will work for FreeBSD, if you are running something else, use your
335  something else, use your imagination to modify them:  imagination to modify them.)
336    
337    <p>
338  <ul>  <ul>
339    <li>On the server, add a line to your /etc/exports file, exporting    <li>On the server, add a line to your /etc/exports file, exporting
340          the files you wish to use in the emulator:<pre>          the files you wish to use in the emulator:<pre>
# Line 374  a CDROM ISO image. You can use a read-wr Line 373  a CDROM ISO image. You can use a read-wr
373  files in both directions, but then you should be aware of the  files in both directions, but then you should be aware of the
374  fragmentation issue mentioned above.  fragmentation issue mentioned above.
375    
 <p>  
 TCP is implemented to some extent, but should not be considered to be  
 stable yet. It is enough to let NetBSD/pmax and OpenBSD/pmax install via  
 ftp, though.  
376    
377    
378    
# Line 498  Each device should have the following: Line 493  Each device should have the following:
493  </ul>  </ul>
494    
495  <p>  <p>
496  The return value of the access function has until 20040702 been a  The return value of the access function has until 2004-07-02 been a
497  true/false value; 1 for success, or 0 for device access failure. A device  true/false value; 1 for success, or 0 for device access failure. A device
498  access failure (on MIPS) will result in a DBE exception.  access failure (on MIPS) will result in a DBE exception.
499    
# Line 512  means that the access failed, and took 5 Line 507  means that the access failed, and took 5
507    
508  <p>  <p>
509  To be compatible with pre-20040702 devices, a return value of 0 is treated  To be compatible with pre-20040702 devices, a return value of 0 is treated
510  by the caller (in src/memory.c) as a value of -1.  by the caller (in <tt>src/memory_rw.c</tt>) as a value of -1.
511    
512    
513    
# Line 524  by the caller (in src/memory.c) as a val Line 519  by the caller (in src/memory.c) as a val
519    
520  In order to make sure that the emulator actually works like it is supposed  In order to make sure that the emulator actually works like it is supposed
521  to, it must be tested. For this purpose, there is a simple regression  to, it must be tested. For this purpose, there is a simple regression
522  testing framework in the <b>tests/</b> directory.  testing framework in the <tt>tests/</tt> directory.
523    
524  <p>  <p>
525  <i>NOTE:  The regression testing framework is basically just a skeleton so far.  <i>NOTE:  The regression testing framework is basically just a skeleton so far.
# Line 534  probably not too incorrect. This makes i Line 529  probably not too incorrect. This makes i
529  regression tests.</i>  regression tests.</i>
530    
531  <p>  <p>
532  To run all the regression tests, type <b>make regtest</b>. Each assembly  To run all the regression tests, type <tt>make regtest</tt>. Each assembly
533  language file matching the pattern <b>test_*.S</b> will be compiled and  language file matching the pattern <tt>test_*.S</tt> will be compiled and
534  linked into a 64-bit MIPS ELF (using a gcc cross compiler), and run in the  linked into a 64-bit MIPS ELF (using a gcc cross compiler), and run in the
535  emulator. If everything goes well, you should see something like this:  emulator. If everything goes well, you should see something like this:
536    
# Line 578  emulator. If everything goes well, you s Line 573  emulator. If everything goes well, you s
573  </pre>  </pre>
574    
575  <p>  <p>
576  Each test writes output to stdout, and there is a <b>test_*.good</b> for  Each test writes output to stdout, and there is a <tt>test_*.good</tt> for
577  each <b>.S</b> file which contains the wanted output. If the actual output  each <tt>.S</tt> file which contains the wanted output. If the actual
578  matches the <b>.good</b> file, then the test passes, otherwise it fails.  output matches the <tt>.good</tt> file, then the test passes, otherwise it
579    fails.
580    
581  <p>  <p>
582  Read <b>tests/README</b> for more information.  Read <tt>tests/README</tt> for more information.
583    
584    
585    

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

  ViewVC Help
Powered by ViewVC 1.1.26