/[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 5 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 6 by dpavlin, Mon Oct 8 16:18:11 2007 UTC
# Line 13  Line 13 
13    
14  <!--  <!--
15    
16  $Id: technical.html,v 1.49 2005/04/16 00:29:45 debug Exp $  $Id: technical.html,v 1.50 2005/05/14 18:31:16 debug Exp $
17    
18  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.
19    
# Line 52  SUCH DAMAGE. Line 52  SUCH DAMAGE.
52  This page describes some of the internals of GXemul.  This page describes some of the internals of GXemul.
53    
54  <p>  <p>
55    <font color="#e00000"><b>NOTE: This page is probably not
56    very up-to-date by now.</b></font>
57    
58    <p>
59  <ul>  <ul>
60    <li><a href="#overview">Overview</a>    <li><a href="#overview">Overview</a>
61    <li><a href="#speed">Speed</a>    <li><a href="#speed">Speed</a>
# Line 128  code into machine code that can be execu Line 132  code into machine code that can be execu
132  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
133  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
134  executed multiple times.  executed multiple times.
135  To run the emulator with binary translation enabled, just add <b>-b</b>  To run the emulator with binary translation enabled, just add
136  to the command line.  <tt><b>-b</b></tt> to the command line.
137    
138  <p>  <p>
139  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 142  all translations are done directly from
142    
143  <p>  <p>
144  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
145  -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
146  before running the configure script, or by using the bintrans_size()  variable before running the configure script, or by using the
147  configuration file option when running the emulator.  <tt>bintrans_size()</tt> configuration file option when running the emulator.
148    
149  <p>  <p>
150  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 153  host's clock. That is, if the emulated O
153  second, it will get approximately 100 interrupts per real second.  second, it will get approximately 100 interrupts per real second.
154    
155  <p>  <p>
156  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
157  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
158  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,
159  -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
160  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
161  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
162  2*40000000 cycles (which will take more time than 2*7000000).  bootup, those 2 seconds will take 2*40000000 cycles (which will take more
163    time than 2*7000000).
164    
165  <p>  <p>
166  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
167  if a mc146818 device is present.  deterministic experiments, if a mc146818 (or similar) device is present.
168    
169  <p>  <p>
170  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 210  As far as I have understood it, there se
210                  connect from the emulated OS to the OS running on the                  connect from the emulated OS to the OS running on the
211                  host, as packets sent out on the host's NIC are not                  host, as packets sent out on the host's NIC are not
212                  received by itself. (?)                  received by itself. (?)
213              <li>All specific networking protocols will be handled by the
214                    physical network.
215          </ul>          </ul>
216    <p>    <p>
217    or    or
# Line 233  As far as I have understood it, there se Line 240  As far as I have understood it, there se
240          </ul>          </ul>
241  </ol>  </ol>
242    
243  Other emulators that I have heard of seem to use the first one, if they  <p>
244  support networking.  Some emulators/simulators use the first approach, while others use the
245    second. I think that SIMH and QEMU are examples of emulators using the
246    first and second approach, respectively.
247    
248  <p>  <p>
249  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 258  emulation (-E dec -e 3max):
258          and converted to ARP responses. (This is used by the emulated OS          and converted to ARP responses. (This is used by the emulated OS
259          to find out the MAC address of the gateway.)          to find out the MAC address of the gateway.)
260    <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
261          <b>ping</b> program) are interpreted and converted to ICMP echo          <b><tt>ping</tt></b> program) are interpreted and converted to ICMP echo
262          replies, <i>regardless of the IP address</i>. This means that          replies, <i>regardless of the IP address</i>. This means that
263          running ping from within the emulated OS will <i>always</i>          running ping from within the emulated OS will <i>always</i>
264          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 272  emulation (-E dec -e 3max):
272          packets are handled (but more state is kept for each connection).          packets are handled (but more state is kept for each connection).
273          <font color="#ff0000">NOTE: Much of the TCP handling code is very          <font color="#ff0000">NOTE: Much of the TCP handling code is very
274          ugly and hardcoded.</font>          ugly and hardcoded.</font>
275    <!--
276    <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.)
277    -->
278  </ul>  </ul>
279    
280    <p>
281  The gateway machine, which is the only "other" machine that the emulated  The gateway machine, which is the only "other" machine that the emulated
282  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
283  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
284  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>;
285    a typical choice would be <tt>10.0.0.1</tt>.
286    
287  <p>  <p>
288  Inside emulated NetBSD or OpenBSD, running the following commands should  Inside emulated NetBSD/pmax or OpenBSD/pmax, running the following
289  configure the emulated NIC:  commands should configure the emulated NIC:
290  <pre>  <pre>
291          # <b>ifconfig le0 10.0.0.1</b>          # <b>ifconfig le0 10.0.0.1</b>
292          # <b>route add default 10.0.0.254</b>          # <b>route add default 10.0.0.254</b>
293          add net default: gateway 10.0.0.254          add net default: gateway 10.0.0.254
294  </pre>  </pre>
295    
296    <p>
297  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
298  as well:  as well:
299  <pre>  <pre>
300          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>
301  </pre>  </pre>
302  (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
303  nearest nameserver.)  your nearest nameserver.)
304    
305  <p>  <p>
306  Now, host lookups should work:  Now, host lookups should work:
307  <pre>  <pre>
# Line 309  Now, host lookups should work: Line 324  Now, host lookups should work:
324          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
325  </pre>  </pre>
326    
327  To transfer files via UDP, you can use the tftp program.  <p>
328    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>  
329    
330  This, of course, requires that you have put the file <i>filename</i> in  <p>
331  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
332    client machine for sharing files via NFS:
333    
334  <p>  <p>
335  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
336  share entire directory trees between the emulated environment and another  between the emulated environment and another machine. These instruction
337  machine. These instruction will work for FreeBSD, if you are running  will work for FreeBSD, if you are running something else, use your
338  something else, use your imagination to modify them:  imagination to modify them.)
339    
340    <p>
341  <ul>  <ul>
342    <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
343          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 376  a CDROM ISO image. You can use a read-wr
376  files in both directions, but then you should be aware of the  files in both directions, but then you should be aware of the
377  fragmentation issue mentioned above.  fragmentation issue mentioned above.
378    
 <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.  
379    
380    
381    
# Line 498  Each device should have the following: Line 496  Each device should have the following:
496  </ul>  </ul>
497    
498  <p>  <p>
499  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
500  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
501  access failure (on MIPS) will result in a DBE exception.  access failure (on MIPS) will result in a DBE exception.
502    
# Line 512  means that the access failed, and took 5 Line 510  means that the access failed, and took 5
510    
511  <p>  <p>
512  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
513  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.
514    
515    
516    
# Line 524  by the caller (in src/memory.c) as a val Line 522  by the caller (in src/memory.c) as a val
522    
523  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
524  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
525  testing framework in the <b>tests/</b> directory.  testing framework in the <tt>tests/</tt> directory.
526    
527  <p>  <p>
528  <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 532  probably not too incorrect. This makes i
532  regression tests.</i>  regression tests.</i>
533    
534  <p>  <p>
535  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
536  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
537  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
538  emulator. If everything goes well, you should see something like this:  emulator. If everything goes well, you should see something like this:
539    
# Line 578  emulator. If everything goes well, you s Line 576  emulator. If everything goes well, you s
576  </pre>  </pre>
577    
578  <p>  <p>
579  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
580  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
581  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
582    fails.
583    
584  <p>  <p>
585  Read <b>tests/README</b> for more information.  Read <tt>tests/README</tt> for more information.
586    
587    
588    

Legend:
Removed from v.5  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26