1 |
<html> |
<html><head><title>Gavare's eXperimental Emulator: Miscellaneous</title> |
2 |
<head><title>GXemul documentation: Misc.</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> |
<b>Gavare's eXperimental Emulator: </b></font> |
8 |
<font color="#000000" size="6"><b>Misc.</b> |
<font color="#000000" size="6"><b>Miscellaneous</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: misc.html,v 1.40 2005/04/16 00:29:45 debug Exp $ |
$Id: misc.html,v 1.54 2005/10/29 07:06:26 debug Exp $ |
14 |
|
|
15 |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
16 |
|
|
39 |
|
|
40 |
--> |
--> |
41 |
|
|
42 |
|
|
43 |
<a href="./">Back to the index</a> |
<a href="./">Back to the index</a> |
44 |
|
|
45 |
<p><br> |
<p><br> |
46 |
<h2>Misc.</h2> |
<h2>Miscellaneous</h2> |
47 |
|
|
48 |
<p> |
<p> |
49 |
<ul> |
<ul> |
50 |
<li><a href="#networking">Networking</a> |
<li><a href="#networking">Networking</a> |
51 |
<li><a href="#portmips">Porting operating systems to MIPS using GXemul</a> |
<li><a href="#devel">Writing operating system code, or |
52 |
|
developing firmware, using GXemul</a> |
53 |
<li><a href="#compilercontruct">Using GXemul in compiler contruction courses</a> |
<li><a href="#compilercontruct">Using GXemul in compiler contruction courses</a> |
54 |
<li><a href="#disk">How to start the emulator with a disk image</a> |
<li><a href="#disk">How to start the emulator with a disk image</a> |
55 |
<li><a href="#largeimages">How to extract large gzipped disk images</a> |
<li><a href="#largeimages">How to extract large gzipped disk images</a> |
89 |
|
|
90 |
|
|
91 |
<p><br> |
<p><br> |
92 |
<a name="portmips"></a> |
<a name="devel"></a> |
93 |
<h3>Porting operating systems to MIPS using GXemul:</h3> |
<h3>Writing operating system code, or developing firmware, using GXemul:</h3> |
94 |
|
|
95 |
|
Is this a good idea? The answer is yes and no, depending on the level of |
96 |
|
detail you need in your simulations. If you are developing an operating |
97 |
|
system or operating system kernel of your own, and wish to target |
98 |
|
MIPS-like systems in general, then the answer might be yes, for |
99 |
|
experimental purposes. |
100 |
|
|
101 |
Is this a good idea? The answer is yes and no, depending on what you are |
<p>Some examples of things that <i>don't</i> work, that you should keep in |
102 |
trying to port to. If you are developing an operating system or operating |
mind: |
|
system kernel of your own, and wish to target MIPS-like systems in general, |
|
|
then the answer might be yes, for experimental purposes. |
|
|
|
|
|
<p> |
|
|
However, if you think that you can port an operating system |
|
|
to, say, the Silicon Graphics machine mode of GXemul and hope that your |
|
|
operating system will run on a real SGI machine, then you will most |
|
|
likely fail. GXemul simply does not emulate things well enough for that to work. |
|
|
Another example would be specific CPU details; if your code depends on, |
|
|
say, R10000 specifics, chances are that GXemul will not be sufficient. |
|
|
|
|
|
<p> |
|
|
In many cases, hardware devices in GXemul are only implemented well |
|
|
enough to fool eg. NetBSD that they are working correctly, while in |
|
|
fact they don't work very much at all. Please keep this in mind, if you plan |
|
|
to use GXemul when porting your code to MIPS. |
|
103 |
|
|
104 |
|
<ul> |
105 |
|
<li>Porting code to a specific machine mode, e.g. a Silicon Graphics |
106 |
|
machine, using GXemul, will not necessarily cause the code to |
107 |
|
work on a real machine. Sometimes code works in GXemul which doesn't |
108 |
|
work on real hardware, sometimes it's the other way around. |
109 |
|
|
110 |
|
<p> |
111 |
|
<li>GXemul contains bugs, and many things are not yet implemented. |
112 |
|
|
113 |
|
<p> |
114 |
|
<li>I have only implemented devices in GXemul to the degree that |
115 |
|
NetBSD, OpenBSD, etc, don't complain too much. One way to say it |
116 |
|
is that the device implementations are "lazy hacks", based on the |
117 |
|
assumption that the emulated OS is already developed and bug-free. |
118 |
|
They are not intended to be used for development of new OS code, |
119 |
|
so if you do that, then be prepared for bugs and inconsitencies. |
120 |
|
|
121 |
|
<p> |
122 |
|
<li>CPU details in GXemul are usually wrong. If your code depends |
123 |
|
on, say, R10000 or MIPS64 specifics, chances are that GXemul will |
124 |
|
not be sufficient. Again, this was done as "lazy hacks", and pretty |
125 |
|
much assumes that the OS being emulated is already developed |
126 |
|
and bug-free. |
127 |
|
|
128 |
|
<p> |
129 |
|
<li>Caches. There is no cache emulation in GXemul right now. Caches |
130 |
|
for R2000/R3000 are faked well enough to run NetBSD, Ultrix, etc |
131 |
|
in the DECstation emulation mode, but other than that, cache |
132 |
|
operations are treated as nops. |
133 |
|
</ul> |
134 |
|
|
135 |
|
<p>The bottom line is that GXemul can be useful as yet another way to test |
136 |
|
your code during development, but it should not be fully relied on. |
137 |
|
|
138 |
|
|
139 |
|
|
180 |
Here are some examples. If you want to run a NetBSD/pmax kernel on an |
Here are some examples. If you want to run a NetBSD/pmax kernel on an |
181 |
emulated DECstation machine, you would use a command line such as this: |
emulated DECstation machine, you would use a command line such as this: |
182 |
<pre> |
<pre> |
183 |
$ <b>gxemul -E dec -e 3max -b -d pmax_diskimage.fs netbsd-pmax-INSTALL</b> |
$ <b>gxemul -e 3max -d pmax_diskimage.fs netbsd-pmax-INSTALL</b> |
184 |
</pre> |
</pre> |
185 |
<p> |
<p> |
186 |
NOTE: For some emulation modes, such as the DECstation mode, you do |
NOTE: For some emulation modes, such as the DECstation mode, you do |
191 |
image is added; the first will be SCSI target 0, the second will be target 1, and so on, |
image is added; the first will be SCSI target 0, the second will be target 1, and so on, |
192 |
unless you specify explicitly which ID number the devices should have. |
unless you specify explicitly which ID number the devices should have. |
193 |
<pre> |
<pre> |
194 |
$ <b>gxemul -E dec -e 3max -b -d disk0.raw -d disk1.raw -d 5:disk2.raw netbsd-pmax-INSTALL</b> |
$ <b>gxemul -e 3max -d disk0.raw -d disk1.raw -d 5:disk2.raw netbsd-pmax-INSTALL</b> |
195 |
</pre> |
</pre> |
196 |
Note: In the example above, disk2.raw will get scsi id 5. |
Note: In the example above, disk2.raw will get scsi id 5. |
197 |
<p> |
<p> |
200 |
For example, the following command would start the emulator with two |
For example, the following command would start the emulator with two |
201 |
CDROM images, and one harddisk image: |
CDROM images, and one harddisk image: |
202 |
<pre> |
<pre> |
203 |
$ <b>gxemul -E dec -e 3max -b -d image.iso -d disk0.img -d c:second_cdrom.img netbsd-pmax-INSTALL</b> |
$ <b>gxemul -e 3max -d image.iso -d disk0.img -d c:second_cdrom.img netbsd-pmax-INSTALL</b> |
204 |
</pre> |
</pre> |
205 |
Usually, the device with the lowest id becomes the boot device. To override |
Usually, the device with the lowest id becomes the boot device. To override |
206 |
this, add a 'b' prefix to one of the devices: |
this, add a 'b' prefix to one of the devices: |
207 |
<pre> |
<pre> |
208 |
$ <b>gxemul -E dec -e 3max -b -d rootdisk.img -d bc:install-cd.iso name_of_kernel</b> |
$ <b>gxemul -e 3max -d rootdisk.img -d bc:install-cd.iso name_of_kernel</b> |
209 |
</pre> |
</pre> |
210 |
If you have a physical CD-ROM drive on the host machine, say /dev/cd0c, you can |
If you have a physical CD-ROM drive on the host machine, say /dev/cd0c, you can |
211 |
use it as a CD-ROM directly accessible from within the emulator: |
use it as a CD-ROM directly accessible from within the emulator: |
212 |
<pre> |
<pre> |
213 |
$ <b>gxemul -E dec -e 3max -b -d rootdisk.img -d bc:/dev/cd0c name_of_kernel</b> |
$ <b>gxemul -e 3max -d rootdisk.img -d bc:/dev/cd0c name_of_kernel</b> |
214 |
</pre> |
</pre> |
215 |
It is probably possible to use harddisks as well this way, but I would not |
It is probably possible to use harddisks as well this way, but I would not |
216 |
recommend it. |
recommend it. |
310 |
<a name="userland"></a> |
<a name="userland"></a> |
311 |
<h3>Running userland binaries:</h3> |
<h3>Running userland binaries:</h3> |
312 |
|
|
313 |
You can run (some) userland programs as well. This will not emulate any |
<font color="#ff0000">Note: This does not really work yet.</font> |
314 |
particular machine, but instead try to translate syscalls from for example |
|
315 |
NetBSD/pmax into the host's OS' syscalls. Right now, this is just a |
<p>There is some skeleton code for running userland programs as well. This |
316 |
proof-of-concept, to show that it would work; there's lots of work left to |
will not emulate any particular machine, but instead try to translate |
317 |
do to make it actually run useful programs (for example dynamically linked |
syscalls from e.g. NetBSD/pmax into the host's OS' syscalls. Right now, |
318 |
programs). |
this is just a proof-of-concept, to show that it could work; there's lots |
319 |
|
of work left to do to make it actually run useful programs. |
320 |
|
|
321 |
<p> |
<p> |
322 |
|
|
347 |
tab.csbnet.se |
tab.csbnet.se |
348 |
</pre> |
</pre> |
349 |
|
|
350 |
|
<!-- |
351 |
<p> |
<p> |
352 |
<li><b>NetBSD/powerpc:</b> |
<li><b>NetBSD/powerpc:</b> |
353 |
<br> |
<br> |
371 |
Hello, world! |
Hello, world! |
372 |
|
|
373 |
</pre> |
</pre> |
374 |
|
--> |
375 |
|
|
376 |
</ul> |
</ul> |
377 |
|
|
439 |
</pre> |
</pre> |
440 |
This binary image can now be used in the emulator: |
This binary image can now be used in the emulator: |
441 |
<pre> |
<pre> |
442 |
$ <b>gxemul -E dec -e 3min -Q -M128 -q 0xbfc00000:DECstation5000_125_promdump.bin</b> |
$ <b>gxemul -e 3min -Q -M128 -q 0xbfc00000:DECstation5000_125_promdump.bin</b> |
443 |
|
|
444 |
KN02-BA V5.7e |
KN02-BA V5.7e |
445 |
?TFL: 3/scc/access (1:Ln1 reg-12: actual=0x00 xpctd=0x01) [KN02-BA] |
?TFL: 3/scc/access (1:Ln1 reg-12: actual=0x00 xpctd=0x01) [KN02-BA] |
480 |
osconsole=3 |
osconsole=3 |
481 |
>> |
>> |
482 |
</pre> |
</pre> |
483 |
<i>(Note: at the moment, this doesn't work. I must have broken something when |
|
484 |
fixing something else, but this is what it looked like at the time.)</i> |
<p><font color="#ff0000">(Note: at the moment, this doesn't work. |
485 |
<p> |
I must have broken something when fixing something else, but this |
486 |
During bootup, the PROM complains <i>a lot</i> about hardware failures. |
is what it looked like at the time.)</font> |
487 |
|
|
488 |
|
<p>During bootup, the PROM complains <i>a lot</i> about hardware failures. |
489 |
That's because the emulator doesn't emulate the hardware well enough yet. |
That's because the emulator doesn't emulate the hardware well enough yet. |
490 |
<p> |
|
491 |
The command line options used are: -E dec for DECstation, -e 3min for |
<p>The command line options used are: <tt>-e 3min</tt> for |
492 |
"model 3" (5000/1xx), -Q to supress the emulator's own PROM |
"DECstation 3min" (5000/1xx), <tt>-Q</tt> to supress the emulator's own PROM |
493 |
call emulation, -M128 for 128MB RAM (because GXemul doesn't correctly |
call emulation, <tt>-M128</tt> for 128MB RAM (because GXemul doesn't correctly |
494 |
emulate memory detection well enough for the PROM to accept, so it will |
emulate memory detection well enough for the PROM to accept, so it will |
495 |
always believe there is 128MB ram anyway), and -q to supress debug messages. |
always believe there is 128MB ram anyway), and <tt>-q</tt> to supress debug messages. |
496 |
The 0xbfc00000 in front of the filename tells GXemul that it is a raw |
The <tt>0xbfc00000</tt> in front of the filename tells GXemul that it is a raw |
497 |
binary file which should be loaded at a specific virtual address. |
binary file which should be loaded at a specific virtual address. |
498 |
|
|
499 |
|
|
501 |
<h4>Dumping the PROM on a SGI O2:</h4> |
<h4>Dumping the PROM on a SGI O2:</h4> |
502 |
|
|
503 |
The general ideas in this section applies to using ROM images from other |
The general ideas in this section applies to using ROM images from other |
504 |
machines as well. Besides DECstation, I've also tried this on an SGI IP32 |
machines as well. I have also tried this on an SGI IP32 ("O2"), in addition |
505 |
("O2"). |
to the DECstation. |
506 |
<p> |
|
507 |
For the O2, a suitable command to dump the prom memory range is |
<p>For the O2, a suitable command to dump the prom memory range is |
508 |
<pre> |
<pre> |
509 |
>> <b>dump -b 0xBFC00000:0xBFC80000</b> |
>> <b>dump -b 0xBFC00000:0xBFC80000</b> |
510 |
</pre> |
</pre> |
511 |
Make sure you capture all the output (via serial console) into a file, |
Make sure you capture all the output (via serial console) into a file, |
512 |
and then run experiments/sgiprom_to_bin on the captured file. |
and then run <tt>experiments/sgiprom_to_bin</tt> on the captured file. |
|
<p> |
|
|
(2005-01-16: The emulator doesn't really emulate the IP32 well enough to |
|
|
actually run the PROM image without using special hacks, but it might do |
|
|
so some time in the future.) |
|
513 |
|
|
514 |
|
<p> |
515 |
|
|
516 |
|
<a href="sgi-o2-real.jpg"><img src="sgi-o2-real_small.jpg"></a> |
517 |
|
|
518 |
|
<a href="20050817-sgi-o2-success-7.png"><img src="20050817-sgi-o2-success-7_small.png"></a> |
519 |
|
|
520 |
|
<a href="20050817-sgi-o2-success-8.png"><img src="20050817-sgi-o2-success-8_small.png"></a> |
521 |
|
|
522 |
|
<p>The photo on the left is from the real machine. The other two are |
523 |
|
screenshots of the PROM running experimentally in GXemul, using <tt>-Y2</tt> |
524 |
|
framebuffer scaledown. |
525 |
|
|
526 |
|
<p>Normally during bootup, the IP32 PROM does a Power-On test which makes |
527 |
|
sure that the caches and other things are working properly. GXemul doesn't |
528 |
|
emulate all those things well enough for the tests to pass. The |
529 |
|
experimental screenshots above were taken with cache detection skipped |
530 |
|
manually. |
531 |
|
|
532 |
|
<p><font color="#ff0000"> |
533 |
|
In other words: don't expect this to work out-of-the-box with GXemul right |
534 |
|
now. It might work once I've added correct cache emulation.</font> |
535 |
|
|
536 |
|
<p>The command line used to start the emulator, once correct cache |
537 |
|
emulation has been implemented, would be something like <tt>gxemul -XQeo2 |
538 |
|
0xbfc00000:prom.bin</tt>. |
539 |
|
|
540 |
|
<p>The same caution applies when dealing with SGI PROMs as with |
541 |
|
DECstation PROMs: GXemul doesn't really emulate the hardware, it only |
542 |
|
"fakes" devices well enough to fool some things, primarily NetBSD, that |
543 |
|
it is emulating a real machine. ROM code is usually a <i>lot</i> more |
544 |
|
picky about the details. |
545 |
|
|
546 |
|
<p>The graphics used in the O2 is (as far as I know) undocumented. Combining |
547 |
|
some traces of info from how Linux/O2 draws to the screen with some |
548 |
|
reverse-engineering of my own, I've implemented enough of the controller to |
549 |
|
let the PROM draw rectangles and bitmaps, but not much more. The SCSI |
550 |
|
controller is not implemented yet either. |
551 |
|
|
552 |
|
|
553 |
|
|