/[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 2 by dpavlin, Mon Oct 8 16:17:48 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  <html>  <html><head><title>Gavare's eXperimental Emulator:&nbsp;&nbsp;&nbsp;Technical details</title>
2  <head><title>GXemul documentation: Technical details</title>  <meta name="robots" content="noarchive,nofollow,noindex"></head>
3  </head>  <body bgcolor="#f8f8f8" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000">
4  <body bgcolor="#ffffff" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000">  <table border=0 width=100% bgcolor="#d0d0d0"><tr>
5  <p>  <td width=100% align=center valign=center><table border=0 width=100%><tr>
6  <table width=100%>  <td align="left" valign=center bgcolor="#d0efff"><font color="#6060e0" size="6">
7    <tr><td width=100% bgcolor=#808070><font color=#ffffe0 size=6>  <b>Gavare's eXperimental Emulator:</b></font><br>
8    <b>GXemul documentation: Technical details</b></font></td></tr>  <font color="#000000" size="6"><b>Technical details</b>
9  </table>  </font></td></tr></table></td></tr></table><p>
 <p>  
 <!-- The first 10 lines are cut away by the homepage updating script.  -->  
   
10    
11  <!--  <!--
12    
13  $Id: technical.html,v 1.47 2005/04/07 15:50:38 debug Exp $  $Id: technical.html,v 1.76 2007/06/15 18:07:08 debug Exp $
14    
15  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.  Copyright (C) 2004-2007  Anders Gavare.  All rights reserved.
16    
17  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
18  modification, are permitted provided that the following conditions are met:  modification, are permitted provided that the following conditions are met:
# Line 43  SUCH DAMAGE. Line 40  SUCH DAMAGE.
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>
47  <h2>Technical details</h2>  <h2>Technical details</h2>
48    
49  <p>  <p>This page describes some of the internals of GXemul.
 This page describes some of the internals of GXemul.  
50    
51  <p>  <p>
52  <ul>  <ul>
53    <li><a href="#overview">Overview</a>    <li><a href="#speed">Speed and emulation modes</a>
   <li><a href="#speed">Speed</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    
59    
60    
 <p><br>  
 <a name="overview"></a>  
 <h3>Overview</h3>  
   
 In simple terms, GXemul is just a simple fetch-and-execute  
 loop; an instruction is fetched from memory, and executed.  
   
 <p>  
 In reality, a lot of things need to be handled. Before each instruction is  
 executed, the emulator checks to see if any interrupts are asserted which  
 are not masked away. If so, then an INT exception is generated. Exceptions  
 cause the program counter to be set to a specific value, and some of the  
 system coprocessor's registers to be set to values signifying what kind of  
 exception it was (an interrupt exception in this case).  
   
 <p>  
 Reading instructions from memory is done through a TLB, a translation  
 lookaside buffer. The TLB on MIPS is software controlled, which means that  
 the program running inside the emulator (for example an operating system  
 kernel) has to take care of manually updating the TLB. Some memory  
 addresses are translated into physical addresses directly, some are  
 translated into valid physical addresses via the TLB, and some memory  
 references are not valid. Invalid memory references cause exceptions.  
   
 <p>  
 After an instruction has been read from memory, the emulator checks which  
 opcode it contains and executes the instruction. Executing an instruction  
 usually involves reading some register and writing some register, or perhaps a  
 load from memory (or a store to memory). The program counter is increased  
 for every instruction.  
   
 <p>  
 Some memory references point to physical addresses which are not in the  
 normal RAM address space. They may point to hardware devices. If that is  
 the case, then loads and stores are converted into calls to a device  
 access function. The device access function is then responsible for  
 handling these reads and writes.  For example, a graphical framebuffer  
 device may put a pixel on the screen when a value is written to it, or a  
 serial controller device may output a character to stdout when written to.  
   
   
61    
62    
63  <p><br>  <p><br>
64  <a name="speed"></a>  <a name="speed"></a>
65  <h3>Speed</h3>  <h3>Speed and emulation modes</h3>
66    
67  There are two modes in which the emulator can run, <b>a</b>) a straight forward  So, how fast is GXemul? There is no short answer to this. There is
68  loop which fetches one instruction from emulated RAM and executes it  especially no answer to the question <b>What is the slowdown factor?</b>,
69  (described in the previous section), and <b>b</b>)  because the host architecture and emulated architecture can usually not be
70  using dynamic binary translation.  compared just like that.
71    
72    <p>Performance depends on several factors, including (but not limited to)  
73    host architecture, target architecture, host clock speed, which compiler
74    and compiler flags were used to build the emulator, what the workload is,
75    what additional runtime flags are given to the emulator, and so on.
76    
77    <p>Devices are generally not timing-accurate: for example, if an emulated
78    operating system tries to read a block from disk, from its point of view
79    the read was instantaneous (no waiting). So 1 MIPS in an emulated OS might
80    have taken more than one million instructions on a real machine.
81    
82    <p>Also, if the emulator says it has executed 1 million instructions, and
83    the CPU family in question was capable of scalar execution (i.e. one cycle
84    per instruction), it might still have taken more than 1 million cycles on
85    a real machine because of cache misses and similar micro-architectural
86    penalties that are not simulated by GXemul.
87    
88    <p>Because of these issues, it is in my opinion best to measure
89    performance as the actual (real-world) time it takes to perform a task
90    with the emulator, e.g.:
91    
92  <p>  <ul>
93  Mode <b>a</b> is very slow. On a 2.8 GHz Intel Xeon host the resulting    <li>"How long does it take to install NetBSD onto a disk image?"
94  emulated machine is rougly equal to a 7 MHz R3000 (or a 3.5 MHz R4000).    <li>"How long does it take to compile XYZ inside NetBSD
95  The actual performance varies a lot, maybe between 5 and 10 million          in the emulator?".
96  instructions per second, depending on workload.  </ul>
   
 <p>  
 Mode <b>b</b> ("bintrans") is still to be considered experimental, but  
 gives higher performance than mode <b>a</b>. It translates MIPS machine  
 code into machine code that can be executed on the host machine  
 on-the-fly. The translation itself obviously takes some time, but this is  
 usually made up for by the fact that the translated code chunks are  
 executed multiple times.  
 To run the emulator with binary translation enabled, just add <b>-b</b>  
 to the command line.  
97    
98  <p>  <p>So, how fast is it? :-)&nbsp;&nbsp;&nbsp;Answer: it varies.
 Only small pieces of MIPS machine code are translated, usually the size of  
 a function, or less. There is no "intermediate representation" code, so  
 all translations are done directly from MIPS to host machine code.  
99    
 <p>  
 The default bintrans cache size is 16 MB, but you can change this by adding  
 -DDEFAULT_BINTRANS_SIZE_IN_MB=<i>xx</i> to your CFLAGS environment variable  
 before running the configure script, or by using the bintrans_size()  
 configuration file option when running the emulator.  
100    
 <p>  
 By default, an emulated OS running under DECstation emulation which listens to  
 interrupts from the mc146818 clock will get interrupts that are close to the  
 host's clock. That is, if the emulated OS says it wants 100 interrupts per  
 second, it will get approximately 100 interrupts per real second.  
101    
 <p>  
 There is however a -I option, which sets the number of emulated cycles per  
 seconds to a fixed value. Let's say you wish to make the emulated OS think it  
 is running on a 40 MHz DECstation, and not a 7 MHz one, then you can add  
 -I 40000000 to the command line. This will not make the emulation faster, of  
 course. It might even make it seem slower; for example, if NetBSD/pmax waits  
 2 seconds for SCSI devices to settle during bootup, those 2 seconds will take  
 2*40000000 cycles (which will take more time than 2*7000000).  
   
 <p>  
 The -I option is also necessary if you want to run deterministic experiments,  
 if a mc146818 device is present.  
   
 <p>  
 Some emulators make claims such as "x times slowdown," but in the case of  
 GXemul, the host is often not a MIPS-based machine, and hence comparing  
 one MIPS instruction to a host instruction doesn't work. Performance depends on  
 a lot of factors, including (but not limited to) host architecture, host speed,  
 which compiler and compiler flags were used to build GXemul, what the  
 workload is, and so on. For example, if an emulated operating system tries  
 to read a block from disk, from its point of view the read was instantaneous  
 (no waiting). So 1 MIPS in an emulated OS might have taken more than one  
 million instructions on a real machine.  Because of this, imho it is best  
 to measure performance as the actual (real-world) time it takes to perform  
 a task with the emulator.  
102    
103    
104    
# Line 181  a task with the emulator. Line 107  a task with the emulator.
107  <a name="net"></a>  <a name="net"></a>
108  <h3>Networking</h3>  <h3>Networking</h3>
109    
110  Running an entire operating system under emulation is very interesting in  <font color="#ff0000">NOTE/TODO: This section is very old.</font>
111  itself, but for several reasons, running a modern OS without access to  
112  TCP/IP networking is a bit akward. Hence, I feel the need to implement TCP/IP  <p>Running an entire operating system under emulation is very interesting
113  (networking) support in the emulator.  in itself, but for several reasons, running a modern OS without access to
114    TCP/IP networking is a bit akward. Hence, I feel the need to implement
115    TCP/IP (networking) support in the emulator.
116    
117  <p>  <p>
118  As far as I have understood it, there seems to be two different ways to go:  As far as I have understood it, there seems to be two different ways to go:
# Line 205  As far as I have understood it, there se Line 133  As far as I have understood it, there se
133                  connect from the emulated OS to the OS running on the                  connect from the emulated OS to the OS running on the
134                  host, as packets sent out on the host's NIC are not                  host, as packets sent out on the host's NIC are not
135                  received by itself. (?)                  received by itself. (?)
136              <li>All specific networking protocols will be handled by the
137                    physical network.
138          </ul>          </ul>
139    <p>    <p>
140    or    or
# Line 233  As far as I have understood it, there se Line 163  As far as I have understood it, there se
163          </ul>          </ul>
164  </ol>  </ol>
165    
166  Other emulators that I have heard of seem to use the first one, if they  <p>
167  support networking.  Some emulators/simulators use the first approach, while others use the
168    second. I think that SIMH and QEMU are examples of emulators using the
169    first and second approach, respectively.
170    
171  <p>  <p>
172  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 181  emulation (-E dec -e 3max):
181          and converted to ARP responses. (This is used by the emulated OS          and converted to ARP responses. (This is used by the emulated OS
182          to find out the MAC address of the gateway.)          to find out the MAC address of the gateway.)
183    <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
184          <b>ping</b> program) are interpreted and converted to ICMP echo          <b><tt>ping</tt></b> program) are interpreted and converted to ICMP echo
185          replies, <i>regardless of the IP address</i>. This means that          replies, <i>regardless of the IP address</i>. This means that
186          running ping from within the emulated OS will <i>always</i>          running ping from within the emulated OS will <i>always</i>
187          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 195  emulation (-E dec -e 3max):
195          packets are handled (but more state is kept for each connection).          packets are handled (but more state is kept for each connection).
196          <font color="#ff0000">NOTE: Much of the TCP handling code is very          <font color="#ff0000">NOTE: Much of the TCP handling code is very
197          ugly and hardcoded.</font>          ugly and hardcoded.</font>
198    <!--
199    <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.)
200    -->
201  </ul>  </ul>
202    
203    <p>
204  The gateway machine, which is the only "other" machine that the emulated  The gateway machine, which is the only "other" machine that the emulated
205  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
206  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
207  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>;
208    a typical choice would be <tt>10.0.0.1</tt>.
209    
210  <p>  <p>
211  Inside emulated NetBSD or OpenBSD, running the following commands should  Inside emulated NetBSD/pmax or OpenBSD/pmax, running the following
212  configure the emulated NIC:  commands should configure the emulated NIC:
213  <pre>  <pre>
214          # <b>ifconfig le0 10.0.0.1</b>          # <b>ifconfig le0 10.0.0.1</b>
215          # <b>route add default 10.0.0.254</b>          # <b>route add default 10.0.0.254</b>
216          add net default: gateway 10.0.0.254          add net default: gateway 10.0.0.254
217  </pre>  </pre>
218    
219    <p>
220  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
221  as well:  as well:
222  <pre>  <pre>
223          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>          # <b>echo nameserver 129.16.1.3 > /etc/resolv.conf</b>
224  </pre>  </pre>
225  (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
226  nearest nameserver.)  your nearest nameserver.)
227    
228  <p>  <p>
229  Now, host lookups should work:  Now, host lookups should work:
230  <pre>  <pre>
# Line 309  Now, host lookups should work: Line 247  Now, host lookups should work:
247          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
248  </pre>  </pre>
249    
250  To transfer files via UDP, you can use the tftp program.  <p>
251    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>  
252    
253  This, of course, requires that you have put the file <i>filename</i> in  <p>
254  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
255    client machine for sharing files via NFS:
256    
257  <p>  <p>
258  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
259  share entire directory trees between the emulated environment and another  between the emulated environment and another machine. These instruction
260  machine. These instruction will work for FreeBSD, if you are running  will work for FreeBSD, if you are running something else, use your
261  something else, use your imagination to modify them:  imagination to modify them.)
262    
263    <p>
264  <ul>  <ul>
265    <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
266          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 299  a CDROM ISO image. You can use a read-wr
299  files in both directions, but then you should be aware of the  files in both directions, but then you should be aware of the
300  fragmentation issue mentioned above.  fragmentation issue mentioned above.
301    
302  <p>  
303  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.  
304    
305    
306    
# Line 386  ftp, though. Line 309  ftp, though.
309  <a name="devices"></a>  <a name="devices"></a>
310  <h3>Emulation of hardware devices</h3>  <h3>Emulation of hardware devices</h3>
311    
312  Each file in the device/ directory is responsible for one hardware device.  Each file called <tt>dev_*.c</tt> in the
313  These are used from src/machine.c, when initializing which hardware a  <a href="../src/devices/"><tt>src/devices/</tt></a> directory is
314  particular machine model will be using, or when adding devices to a  responsible for one hardware device. These are used from
315  machine using the <b>device()</b> command in configuration files.  <a href="../src/machines/"><tt>src/machines</tt></a><tt>/machine_*.c</tt>,
316    when initializing which hardware a particular machine model will be using,
317  <p>  or when adding devices to a machine using the <tt>device()</tt> command in
318  <font color="#ff0000">NOTE: 2005-02-26: I'm currently rewriting the  <a href="configfiles.html">configuration files</a>.
 device registry subsystem.</font>  
319    
320  <p>  <p>(I'll be using the name "<tt>foo</tt>" as the name of the device in all
321  (I'll be using the name 'foo' as the name of the device in all these  these examples.  This is pseudo code, it might need some modification to
 examples.  This is pseudo code, it might need some modification to  
322  actually compile and run.)  actually compile and run.)
323    
324  <p>  <p>Each device should have the following:
 Each device should have the following:  
325    
326  <p>  <p>
327  <ul>  <ul>
328    <li>A devinit function in dev_foo.c. It would typically look    <li>A <tt>devinit</tt> function in <tt>src/devices/dev_foo.c</tt>. It
329          something like this:          would typically look something like this:
330  <pre>  <pre>
331          /*          DEVINIT(foo)
          *  devinit_foo():  
          */  
         int devinit_foo(struct devinit *devinit)  
332          {          {
333                  struct foo_data *d = malloc(sizeof(struct foo_data));                  struct foo_data *d;
334    
335                  if (d == NULL) {                  CHECK_ALLOCATION(d = malloc(sizeof(struct foo_data)));
336                          fprintf(stderr, "out of memory\n");                  memset(d, 0, sizeof(struct foo_data));
                         exit(1);  
                 }  
                 memset(d, 0, sizeof(struct foon_data));  
337    
338                  /*                  /*
339                   *  Set up stuff here, for example fill d with useful                   *  Set up stuff here, for example fill d with useful
340                   *  data. devinit contains settings like address, irq_nr,                   *  data. devinit contains settings like address, irq path,
341                   *  and other things.                   *  and other things.
342                   *                   *
343                   *  ...                   *  ...
344                   */                   */
345    
346                    INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
347                    
348                  memory_device_register(devinit->machine->memory, devinit->name,                  memory_device_register(devinit->machine->memory, devinit->name,
349                      devinit->addr, DEV_FOO_LENGTH,                      devinit->addr, DEV_FOO_LENGTH,
350                      dev_foo_access, (void *)d, MEM_DEFAULT, NULL);                      dev_foo_access, (void *)d, DM_DEFAULT, NULL);
351                    
352                  /*  This should only be here if the device                  /*  This should only be here if the device
353                      has a tick function:  */                      has a tick function:  */
# Line 443  Each device should have the following: Line 359  Each device should have the following:
359          }                }      
360  </pre><br>  </pre><br>
361    
362    <li>At the top of dev_foo.c, the foo_data struct should be defined.          <p><tt>DEVINIT(foo)</tt> is defined as <tt>int devinit_foo(struct devinit *devinit)</tt>,
363            and the <tt>devinit</tt> argument contains everything that the device driver's
364            initialization function needs.
365    
366      <p>
367      <li>At the top of <tt>dev_foo.c</tt>, the <tt>foo_data</tt> struct
368            should be defined.
369  <pre>  <pre>
370          struct foo_data {          struct foo_data {
371                  int     irq_nr;                  struct interrupt        irq;
372                  /*  ...  */                  /*  ...  */
373          }          }
374  </pre><br>  </pre><br>
375            (There is an exception to this rule; some legacy code and other
376    <li>If foo has a tick function (that is, something that needs to be          ugly hacks have their device structs defined in
377          run at regular intervals) then FOO_TICKSHIFT and a tick function          <tt>src/include/devices.h</tt> instead of <tt>dev_foo.c</tt>.
378          need to be defined as well:          New code should not add stuff to <tt>devices.h</tt>.)
379      <p>
380      <li>If <tt>foo</tt> has a tick function (that is, something that needs to be
381            run at regular intervals) then <tt>FOO_TICKSHIFT</tt> and a tick
382            function need to be defined as well:
383  <pre>  <pre>
384          #define FOO_TICKSHIFT           10          #define FOO_TICKSHIFT           14
385    
386          void dev_foo_tick(struct cpu *cpu, void *extra)          DEVICE_TICK(foo)
387          {          {
388                  struct foo_data *d = (struct foo_data *) extra;                  struct foo_data *d = extra;
389    
390                  if (.....)                  if (.....)
391                          cpu_interrupt(cpu, d->irq_nr);                          INTERRUPT_ASSERT(d->irq);
392                  else                  else
393                          cpu_interrupt_ack(cpu, d->irq_nr);                          INTERRUPT_DEASSERT(d->irq);
394          }          }
395  </pre><br>  </pre><br>
396    
397      <li>Does this device belong to a standard bus?
398            <ul>
399              <li>If this device should be detectable as a PCI device, then
400                    glue code should be added to
401                    <tt>src/devices/bus_pci.c</tt>.
402              <li>If this is a legacy ISA device which should be usable by
403                    any machine which has an ISA bus, then the device should
404                    be added to <tt>src/devices/bus_isa.c</tt>.
405            </ul>
406      <p>
407    <li>And last but not least, the device should have an access function.    <li>And last but not least, the device should have an access function.
408          The access function is called whenever there is a load or store          The access function is called whenever there is a load or store
409          to an address which is in the device' memory mapped region.          to an address which is in the device' memory mapped region. To
410  <pre>          simplify things a little, a macro <tt>DEVICE_ACCESS(x)</tt>
411          int dev_foo_access(struct cpu *cpu, struct memory *mem,          is expanded into<pre>
412            int dev_x_access(struct cpu *cpu, struct memory *mem,
413              uint64_t relative_addr, unsigned char *data, size_t len,              uint64_t relative_addr, unsigned char *data, size_t len,
414              int writeflag, void *extra)              int writeflag, void *extra)
415    </pre>  The access function can look like this:
416    <pre>
417            DEVICE_ACCESS(foo)
418          {          {
419                  struct foo_data *d = extra;                  struct foo_data *d = extra;
420                  uint64_t idata = 0, odata = 0;                  uint64_t idata = 0, odata = 0;
421    
422                  idata = memory_readmax64(cpu, data, len);                  if (writeflag == MEM_WRITE)
423                            idata = memory_readmax64(cpu, data, len);
424    
425                  switch (relative_addr) {                  switch (relative_addr) {
426                  /* .... */  
427                    /*  Handle accesses to individual addresses within
428                        the device here.  */
429    
430                    /*  ...  */
431    
432                  }                  }
433    
434                  if (writeflag == MEM_READ)                  if (writeflag == MEM_READ)
# Line 498  Each device should have the following: Line 445  Each device should have the following:
445  </ul>  </ul>
446    
447  <p>  <p>
448  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
449  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
450  access failure (on MIPS) will result in a DBE exception.  access failure (on MIPS) will result in a DBE exception.
451    
# Line 512  means that the access failed, and took 5 Line 459  means that the access failed, and took 5
459    
460  <p>  <p>
461  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
462  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.
   
   
   
   
   
 <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 <b>tests/</b> 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>  
463    
 <p>  
 To run all the regression tests, type <b>make regtest</b>. Each assembly  
 language file matching the pattern <b>test_*.S</b> 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  
464    
         ----------------  
 </pre>  
   
 <p>  
 Each test writes output to stdout, and there is a <b>test_*.good</b> for  
 each <b>.S</b> file which contains the wanted output. If the actual output  
 matches the <b>.good</b> file, then the test passes, otherwise it fails.  
   
 <p>  
 Read <b>tests/README</b> for more information.  
465    
466    
467    

Legend:
Removed from v.2  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26