/[gxemul]/trunk/doc/misc.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

Annotation of /trunk/doc/misc.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (hide annotations)
Mon Oct 8 16:22:32 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/html
File size: 23586 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1613 2007/06/15 20:11:26 debug Exp $
20070501	Continuing a little on m88k disassembly (control registers,
		more instructions).
		Adding a dummy mvme88k machine mode.
20070502	Re-adding MIPS load/store alignment exceptions.
20070503	Implementing more of the M88K disassembly code.
20070504	Adding disassembly of some more M88K load/store instructions.
		Implementing some relatively simple M88K instructions (br.n,
		xor[.u] imm, and[.u] imm).
20070505	Implementing M88K three-register and, or, xor, and jmp[.n],
		bsr[.n] including function call trace stuff.
		Applying a patch from Bruce M. Simpson which implements the
		SYSCON_BOARD_CPU_CLOCK_FREQ_ID object of the syscon call in
		the yamon PROM emulation.
20070506	Implementing M88K bb0[.n] and bb1[.n], and skeletons for
		ldcr and stcr (although no control regs are implemented yet).
20070509	Found and fixed the bug which caused Linux for QEMU_MIPS to
		stop working in 0.4.5.1: It was a faulty change to the MIPS
		'sc' and 'scd' instructions I made while going through gcc -W
		warnings on 20070428.
20070510	Updating the Linux/QEMU_MIPS section in guestoses.html to
		use mips-test-0.2.tar.gz instead of 0.1.
		A big thank you to Miod Vallat for sending me M88K manuals.
		Implementing more M88K instructions (addu, subu, div[u], mulu,
		ext[u], clr, set, cmp).
20070511	Fixing bugs in the M88K "and" and "and.u" instructions (found
		by comparing against the manual).
		Implementing more M88K instructions (mask[.u], mak, bcnd (auto-
		generated)) and some more control register details.
		Cleanup: Removing the experimental AVR emulation mode and
		corresponding devices; AVR emulation wasn't really meaningful.
		Implementing autogeneration of most M88K loads/stores. The
		rectangle drawing demo (with -O0) for M88K runs :-)
		Beginning on M88K exception handling.
		More M88K instructions: tb0, tb1, rte, sub, jsr[.n].
		Adding some skeleton MVME PROM ("BUG") emulation.
20070512	Fixing a bug in the M88K cmp instruction.
		Adding the M88K lda (scaled register) instruction.
		Fixing bugs in 64-bit (32-bit pairs) M88K loads/stores.
		Removing the unused tick_hz stuff from the machine struct.
		Implementing the M88K xmem instruction. OpenBSD/mvme88k gets
		far enough to display the Copyright banner :-)
		Implementing subu.co (guess), addu.co, addu.ci, ff0, and ff1.
		Adding a dev_mvme187, for MVME187-specific devices/registers.
		OpenBSD/mvme88k prints more boot messages. :)
20070515	Continuing on MVME187 emulation (adding more devices, beginning
		on the CMMUs, etc).
		Adding the M88K and.c, xor.c, and or.c instructions, and making
		sure that mul, div, etc cause exceptions if executed when SFD1
		is disabled.
20070517	Continuing on M88K and MVME187 emulation in general; moving
		the CMMU registers to the CPU struct, separating dev_pcc2 from
		dev_mvme187, and beginning on memory_m88k.c (BATC and PATC).
		Fixing a bug in 64-bit (32-bit pairs) M88K fast stores.
		Implementing the clock part of dev_mk48txx.
		Implementing the M88K fstcr and xcr instructions.
		Implementing m88k_cpu_tlbdump().
		Beginning on the implementation of a separate address space
		for M88K .usr loads/stores.
20070520	Removing the non-working (skeleton) Sandpoint, SonyNEWS, SHARK
		Dnard, and Zaurus machine modes.
		Experimenting with dyntrans to_be_translated read-ahead. It
		seems to give a very small performance increase for MIPS
		emulation, but a large performance degradation for SuperH. Hm.
20070522	Disabling correct SuperH ITLB emulation; it does not seem to be
		necessary in order to let SH4 guest OSes run, and it slows down
		userspace code.
		Implementing "samepage" branches for SuperH emulation, and some
		other minor speed hacks.
20070525	Continuing on M88K memory-related stuff: exceptions, memory
		transaction register contents, etc.
		Implementing the M88K subu.ci instruction.
		Removing the non-working (skeleton) Iyonix machine mode.
		OpenBSD/mvme88k reaches userland :-), starts executing
		/sbin/init's instructions, and issues a few syscalls, before
		crashing.
20070526	Fixing bugs in dev_mk48txx, so that OpenBSD/mvme88k detects
		the correct time-of-day.
		Implementing a generic IRQ controller for the test machines
		(dev_irqc), similar to a proposed patch from Petr Stepan.
		Experimenting some more with translation read-ahead.
		Adding an "expect" script for automated OpenBSD/landisk
		install regression/performance tests.
20070527	Adding a dummy mmEye (SH3) machine mode skeleton.
		FINALLY found the strange M88K bug I have been hunting: I had
		not emulated the SNIP value for exceptions occurring in
		branch delay slots correctly.
		Implementing correct exceptions for 64-bit M88K loads/stores.
		Address to symbol lookups are now disabled when M88K is
		running in usermode (because usermode addresses don't have
		anything to do with supervisor addresses).
20070531	Removing the mmEye machine mode skeleton.
20070604	Some minor code cleanup.
20070605	Moving src/useremul.c into a subdir (src/useremul/), and
		cleaning up some more legacy constructs.
		Adding -Wstrict-aliasing and -fstrict-aliasing detection to
		the configure script.
20070606	Adding a check for broken GCC on Solaris to the configure
		script. (GCC 3.4.3 on Solaris cannot handle static variables
		which are initialized to 0 or NULL. :-/)
		Removing the old (non-working) ARC emulation modes: NEC RD94,
		R94, R96, and R98, and the last traces of Olivetti M700 and
		Deskstation Tyne.
		Removing the non-working skeleton WDSC device (dev_wdsc).
20070607	Thinking about how to use the host's cc + ld at runtime to
		generate native code. (See experiments/native_cc_ld_test.i
		for an example.)
20070608	Adding a program counter sampling timer, which could be useful
		for native code generation experiments.
		The KN02_CSR_NRMMOD bit in the DECstation 5000/200 (KN02) CSR
		should always be set, to allow a 5000/200 PROM to boot.
20070609	Moving out breakpoint details from the machine struct into
		a helper struct, and removing the limit on max nr of
		breakpoints.
20070610	Moving out tick functions into a helper struct as well (which
		also gets rid of the max limit).
20070612	FINALLY figured out why Debian/DECstation stopped working when
		translation read-ahead was enabled: in src/memory_rw.c, the
		call to invalidate_code_translation was made also if the
		memory access was an instruction load (if the page was mapped
		as writable); it shouldn't be called in that case.
20070613	Implementing some more MIPS32/64 revision 2 instructions: di,
		ei, ext, dext, dextm, dextu, and ins.
20070614	Implementing an instruction combination for the NetBSD/arm
		idle loop (making the host not use any cpu if NetBSD/arm
		inside the emulator is not using any cpu).
		Increasing the nr of ARM VPH entries from 128 to 384.
20070615	Removing the ENABLE_arch stuff from the configure script, so
		that all included architectures are included in both release
		and development builds.
		Moving memory related helper functions from misc.c to memory.c.
		Adding preliminary instructions for netbooting NetBSD/pmppc to
		guestoses.html; it doesn't work yet, there are weird timeouts.
		Beginning a total rewrite of the userland emulation modes
		(removing all emulation modes, beginning from scratch with
		NetBSD/MIPS and FreeBSD/Alpha only).
20070616	After fixing a bug in the DEC21143 NIC (the TDSTAT_OWN bit was
		only cleared for the last segment when transmitting, not all
		segments), NetBSD/pmppc boots with root-on-nfs without the
		timeouts. Updating guestoses.html.
		Removing the skeleton PSP (Playstation Portable) mode.
		Moving X11-related stuff in the machine struct into a helper
		struct.
		Cleanup of out-of-memory checks, to use a new CHECK_ALLOCATION
		macro (which prints a meaningful error message).
		Adding a COMMENT to each machine and device (for automagic
		.index comment generation).
		Doing regression testing for the next release.

==============  RELEASE 0.4.6  ==============


1 dpavlin 12 <html><head><title>Gavare's eXperimental Emulator:&nbsp;&nbsp;&nbsp;Miscellaneous</title>
2 dpavlin 8 <meta name="robots" content="noarchive,nofollow,noindex"></head>
3 dpavlin 4 <body bgcolor="#f8f8f8" text="#000000" link="#4040f0" vlink="#404040" alink="#ff0000">
4     <table border=0 width=100% bgcolor="#d0d0d0"><tr>
5     <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">
7 dpavlin 22 <b>Gavare's eXperimental Emulator:</b></font><br>
8 dpavlin 12 <font color="#000000" size="6"><b>Miscellaneous</b>
9 dpavlin 4 </font></td></tr></table></td></tr></table><p>
10 dpavlin 2
11     <!--
12    
13 dpavlin 42 $Id: misc.html,v 1.70 2007/06/15 06:26:20 debug Exp $
14 dpavlin 2
15 dpavlin 34 Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
16 dpavlin 2
17     Redistribution and use in source and binary forms, with or without
18     modification, are permitted provided that the following conditions are met:
19    
20     1. Redistributions of source code must retain the above copyright
21     notice, this list of conditions and the following disclaimer.
22     2. Redistributions in binary form must reproduce the above copyright
23     notice, this list of conditions and the following disclaimer in the
24     documentation and/or other materials provided with the distribution.
25     3. The name of the author may not be used to endorse or promote products
26     derived from this software without specific prior written permission.
27    
28     THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
29     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31     ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
32     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38     SUCH DAMAGE.
39    
40     -->
41    
42 dpavlin 12
43 dpavlin 2 <a href="./">Back to the index</a>
44    
45     <p><br>
46 dpavlin 12 <h2>Miscellaneous</h2>
47 dpavlin 2
48     <p>
49     <ul>
50 dpavlin 12 <li><a href="#devel">Writing operating system code, or
51     developing firmware, using GXemul</a>
52 dpavlin 2 <li><a href="#compilercontruct">Using GXemul in compiler contruction courses</a>
53     <li><a href="#disk">How to start the emulator with a disk image</a>
54 dpavlin 38 <li><a href="#tape_images">How to start the emulator with tape images</a>
55     <li><a href="#disk_overlays">How to use disk image overlays</a>
56 dpavlin 20 <li><a href="#filexfer">Transfering files to/from the guest OS</a>
57 dpavlin 2 <li><a href="#largeimages">How to extract large gzipped disk images</a>
58     <li><a href="#userland">Running userland binaries</a>
59     <li><a href="#promdump">Using a PROM dump from a real machine</a>
60     </ul>
61    
62    
63    
64    
65    
66    
67    
68    
69    
70     <p><br>
71 dpavlin 12 <a name="devel"></a>
72     <h3>Writing operating system code, or developing firmware, using GXemul:</h3>
73 dpavlin 2
74 dpavlin 12 Is this a good idea? The answer is yes and no, depending on the level of
75     detail you need in your simulations. If you are developing an operating
76 dpavlin 20 system or operating system kernel of your own, then the emulator can be a
77     complement to testing on real hardware.
78 dpavlin 2
79 dpavlin 20 <p>Important things to keep in mind:
80 dpavlin 2
81 dpavlin 12 <ul>
82     <li>Porting code to a specific machine mode, e.g. a Silicon Graphics
83 dpavlin 20 machine, using GXemul, will not "magically" cause the code to
84 dpavlin 12 work on a real machine. Sometimes code works in GXemul which doesn't
85     work on real hardware, sometimes it's the other way around.
86 dpavlin 2
87 dpavlin 12 <p>
88     <li>GXemul contains bugs, and many things are not yet implemented.
89 dpavlin 2
90 dpavlin 12 <p>
91 dpavlin 20 <li><b>Very important!</b> I have only implemented devices in GXemul
92     to the degree that NetBSD, OpenBSD, Linux, etc don't complain too much.
93 dpavlin 12 <p>
94 dpavlin 20 If you are developing a driver for a device which is emulated by
95     GXemul, and your driver does not seem to be working, then the
96     probability of a bug in GXemul's implementation of the device is
97     very much higher than that of a bug in your driver.
98     <p>
99     The device implementations in GXemul are based on the assumption
100     that the emulated OS is already developed and bug-free. They are
101     not primarily intended to be used for development of new device
102     driver code in operating systems, so if you do that, then be
103     prepared for bugs and inconsitencies.
104     <p>
105 dpavlin 12 <li>CPU details in GXemul are usually wrong. If your code depends
106     on, say, R10000 or MIPS64 specifics, chances are that GXemul will
107 dpavlin 20 not be sufficient. One example is different revisions of ISAs;
108 dpavlin 32 some instructions which should trigger an exception on a
109     real MIPS processor usually execute anyway in GXemul. Another
110 dpavlin 20 example is if userland code tries to access kernel memory; in some
111     cases there is protection against this, but not in all cases (to get
112     higher performance).
113 dpavlin 12 <p>
114     <li>Caches. There is no cache emulation in GXemul right now. Caches
115     for R2000/R3000 are faked well enough to run NetBSD, Ultrix, etc
116     in the DECstation emulation mode, but other than that, cache
117     operations are treated as nops.
118     </ul>
119 dpavlin 2
120 dpavlin 12 <p>The bottom line is that GXemul can be useful as yet another way to test
121     your code during development, but it should not be fully relied on.
122 dpavlin 2
123    
124 dpavlin 12
125    
126    
127    
128 dpavlin 2 <p><br>
129     <a name="compilercontruct"></a>
130     <h3>Using GXemul in compiler contruction courses:</h3>
131    
132     If you are learning how to write a compiler, and wish to target a
133 dpavlin 20 realistic target platform, then MIPS or ARM (as emulated by GXemul)
134     might be suitable choices.
135 dpavlin 2
136     <ul>
137     <li><b>(+)</b>&nbsp;&nbsp;Your compiler needs to output real assembly
138 dpavlin 24 language code, which the assembler (e.g. gas, the GNU assembler) can
139 dpavlin 2 then compile into object format, and then you need to link this
140     into an executable image. This is much closer to how things work
141     in real life than running assembly language listings in a simulator
142 dpavlin 24 (e.g. SPIM).
143 dpavlin 2 <p>
144     <li><b>(-)</b>&nbsp;&nbsp;GXemul does not simulate out-of-order
145     execution, penalties related to instruction scheduling, or
146     load-delays, so it cannot be used to create optimizing compilers
147     that take advantage of such processor features. GXemul keeps
148     track of the number of instructions executed, but that's it.
149     </ul>
150    
151    
152    
153    
154    
155    
156     <p><br>
157     <a name="disk"></a>
158     <h3>How to start the emulator with a disk image:</h3>
159    
160     Add <i>-d [prefixes:]diskimagefilename</i> to the command line, where prefixes
161     are one or more single-character options. Run <b>gxemul -h</b>
162     to get a list of possible options.
163    
164     <p>
165     Here are some examples. If you want to run a NetBSD/pmax kernel on an
166     emulated DECstation machine, you would use a command line such as this:
167     <pre>
168 dpavlin 12 $ <b>gxemul -e 3max -d pmax_diskimage.fs netbsd-pmax-INSTALL</b>
169 dpavlin 2 </pre>
170 dpavlin 20
171     <p>NOTE: For some emulation modes, such as the DECstation mode, you do
172     <i>not</i> actually have to specify the name of the kernel, if the disk
173     image is bootable!
174    
175     <p>It is possible to have more than one disk. For each -d argument, a disk
176 dpavlin 2 image is added; the first will be SCSI target 0, the second will be target 1, and so on,
177     unless you specify explicitly which ID number the devices should have.
178     <pre>
179 dpavlin 12 $ <b>gxemul -e 3max -d disk0.raw -d disk1.raw -d 5:disk2.raw netbsd-pmax-INSTALL</b>
180 dpavlin 2 </pre>
181     Note: In the example above, disk2.raw will get scsi id 5.
182 dpavlin 20
183     <p>If a filename has a 'c' prefix, or ends with ".iso", then it is assumed to be
184 dpavlin 2 a CDROM device (this can be overridden with a 'd' prefix, to force a read/write disk).
185     For example, the following command would start the emulator with two
186     CDROM images, and one harddisk image:
187     <pre>
188 dpavlin 12 $ <b>gxemul -e 3max -d image.iso -d disk0.img -d c:second_cdrom.img netbsd-pmax-INSTALL</b>
189 dpavlin 2 </pre>
190     Usually, the device with the lowest id becomes the boot device. To override
191     this, add a 'b' prefix to one of the devices:
192     <pre>
193 dpavlin 12 $ <b>gxemul -e 3max -d rootdisk.img -d bc:install-cd.iso name_of_kernel</b>
194 dpavlin 2 </pre>
195     If you have a physical CD-ROM drive on the host machine, say /dev/cd0c, you can
196     use it as a CD-ROM directly accessible from within the emulator:
197     <pre>
198 dpavlin 12 $ <b>gxemul -e 3max -d rootdisk.img -d bc:/dev/cd0c name_of_kernel</b>
199 dpavlin 2 </pre>
200     It is probably possible to use harddisks as well this way, but I would not
201     recommend it.
202 dpavlin 38
203    
204    
205    
206    
207    
208     <p><br>
209     <a name="tape_images"></a>
210     <h3>How to start the emulator with tape images:</h3>
211    
212 dpavlin 2 Using emulated tape drives is a bit more complicated than disks, because a
213     tape can be made up of several "files" with space in between. The solution
214     I have choosen is to have one file in the host's file system space for each
215     tape file. The prefix for using tapes is 't', and the filename given is
216     for the <i>first</i> file on that tape (number zero, implicitly). For
217     files following file nr 0, a dot and the filenumber is appended to the
218     filename.
219     <p>
220     As an example, starting the emulator with
221     <pre>
222     <b>-d t4:mytape.img</b>
223     </pre>
224     will cause SCSI id 4 to be a tape device, using the following file number
225     to name translation scheme:
226     <p>
227     <center>
228     <table border="0">
229     <tr>
230     <td><b>File number:</b></td>
231     <td><b>File name in the host's filesystem:</b></td>
232     </tr>
233     <tr>
234     <td align="center">0</td>
235     <td align="left">mytape.img</td>
236     </tr>
237     <tr>
238     <td align="center">1</td>
239     <td align="left">mytape.img.1</td>
240     </tr>
241     <tr>
242     <td align="center">2</td>
243     <td align="left">mytape.img.2</td>
244     </tr>
245     <tr>
246     <td align="center">..</td>
247     <td align="left">..</td>
248     </tr>
249     </table>
250     </center>
251     <p>
252     If you already have a number of tape files, which should be placed on the
253     same emulated tape, then you might not want to rename all those files.
254     Use symbolic links instead (ln -s).
255     <p>
256     There is another advantage to using symbolic links for tape filenames:
257     every time a tape is rewound, it is reopened using the filename given
258     on the command line. By changing what the symbolic name points to,
259     you can "switch tapes" without quiting and restarting the emulator.
260    
261 dpavlin 38 <p>
262     <font color="#ff0000">Note: Tape support is most likely very buggy,
263     because it has not been tested much, and has probably also suffered
264     from bit-rot by now.</font>
265 dpavlin 2
266    
267 dpavlin 20
268    
269    
270 dpavlin 38
271 dpavlin 2 <p><br>
272 dpavlin 38 <a name="disk_overlays"></a>
273     <h3>How to use disk image overlays:</h3>
274    
275     This is most likely best understood by an example:
276    
277     <p><ul>
278     <li>Install e.g. <a href="guestoses.html#netbsdcatsinstall">NetBSD/cats</a>.
279     You will end up with a disk image called
280     <tt>nbsd_cats.img</tt>.
281     <p>
282     <li>Running the following command will boot straight from the disk
283     image, with no overlay images:<pre>
284     <b>gxemul -XEcats -d nbsd_cats.img netbsd.aout-GENERIC.gz</b>
285    
286     </pre>
287     <li>You may now create an overlay file, a corresponding map file,
288     and start the emulator with the overlay image connected to
289     the same (explicit) ID as the base disk image:<pre>
290     <b>touch overlay.img overlay.img.map
291     gxemul -XEcats -d 0:nbsd_cats.img -d V0:overlay.img netbsd.aout-GENERIC.gz</b>
292    
293     </pre>
294     <li>Any changes to the filesystem you perform when using the overlay
295     will only be written to that overlay. For example, to perform
296     a "roll back", you can do the following:<pre>
297     <b>rm -f overlay.img overlay.img.map
298     touch overlay.img overlay.img.map</b>
299    
300     </pre>
301     and then simply start the emulator again, with the newly created
302     overlay image.
303     </ul>
304    
305     <p>It is also possible to add multiple overlays. In that case, writes
306     always go the the <i>last</i> added overlay.
307    
308     <p>GXemul uses Unix' way of supporting files with "holes",
309     so even if <tt>ls -l overlay.img</tt> says that the overlay is several
310     gigabytes large, <tt>du overlay.img</tt> should reveal that only the
311     blocks that have actually been written to have been stored in the
312     overlay, e.g.:<pre>
313     <b>$ ls -l
314     ..
315     -rw-r--r-- 1 debug wheel 3072319488 Mar 24 11:59 nbsd_cats.img
316     -rw-r--r-- 1 debug wheel 2465354 Mar 24 11:44 netbsd.aout-GENERIC.gz
317     -rw-r--r-- 1 debug wheel 2930841600 Mar 24 14:02 overlay.img
318     -rw-r--r-- 1 debug wheel 715538 Mar 24 14:02 overlay.img.map
319     $ du overlay.img
320     864 overlay.img
321     </b>
322     </pre>
323    
324     <p>The .map file is simply a raw bitmap telling which blocks of the
325     overlay file that are in use.
326    
327    
328    
329    
330    
331     <p><br>
332 dpavlin 20 <a name="filexfer"></a>
333     <h3>Transfering files to/from the guest OS:</h3>
334    
335 dpavlin 32 If the emulated machine supports networking (see <a
336 dpavlin 40 href="networking.html#intro">this section</a> for more info), then the easiest
337     way to transfer files is probably to use FTP or similar methods.
338 dpavlin 20
339     <p>There is another way of transfering files which works for any kind of
340     emulated machine which supports disks (either SCSI or IDE). Any file can
341     be supplied as a disk image. For example, consider the following:<pre>
342     $ <b>gxemul -XEcats -d nbsd_cats.img -d archive.tar.gz netbsd-GENERIC</b>
343     </pre>
344     This will start NetBSD/cats with <tt>nbsd_cats.img</tt> as IDE master on
345     controller 0 (wd0), and <tt>archive.tar.gz</tt> as IDE slave on controller
346     0 (wd1). From inside NetBSD, it is now possible to extract the files using
347     the following command:<pre>
348     (inside emulated NetBSD/cats)
349     # <b>tar zxvf /dev/wd1c</b>
350     </pre>
351     Don't worry if NetBSD complains about lack of disklabel; it doesn't
352     matter. On some machines, NetBSD uses <tt>wd1d</tt> instead of
353     <tt>wd1c</tt> for the entire disk.
354     There is also a minor problem: reading the end of the disk image. If you
355     experience problems untaring archives like this, then pad out the archive
356     first with some zeroes.
357    
358     <p>Transfering files <i>out</i> from the emulated operating system to the
359     host can be done the same way. First, prepare an empty archive file:<pre>
360     $ <b>dd if=/dev/zero of=newarchive.tar bs=1024 count=1 seek=10000</b>
361     </pre>This example created a 10 MB empty file. Then, start the emulator
362     like this:<pre>
363     $ <b>gxemul -XEcats -d nbsd_cats.img -d archive.tar netbsd-GENERIC</b>
364     </pre>
365     and transfer files by creating an archive directly onto the disk image:<pre>
366     (inside emulated NetBSD/cats)
367     # <b>tar cvf /dev/wd1c filenames</b>
368     </pre>
369     where filenames are the files or directories to transfer.
370    
371    
372    
373    
374    
375     <p><br>
376 dpavlin 2 <a name="largeimages"></a>
377     <h3>How to extract large gzipped disk images:</h3>
378    
379     Unix filesystems usually support large files with "holes". Holes are
380     zero-filled blocks that don't actually exist on disk. This is very
381     practical for emulated disk images, as it is possible to create a very
382     large disk image without using up much space at all.
383    
384     <p>
385     Using gzip and gunzip on disk images can be <i>very</i> slow, as these
386     files can be multiple gigabytes large, but this is usually necessary for
387     transfering disk images over the internet. If you receive a gzipped disk
388     image, say disk.img.gz, and run a naive
389     <p>
390     <pre>
391     $ <b>gunzip disk.img.gz</b>
392     </pre>
393     <p>
394     on it, you will not end up with an optimized file unless
395     gunzip supports that. (In my experiments, it doesn't.) In plain English,
396     if you type <b>ls -l</b> and the filesize is 9 GB, it will actually occupy
397     9 GB of disk space! This is often unacceptable.
398     <p>
399     Using a simple tool which only writes blocks that are non-zero, a lot of
400     space can be saved. Compile the program cp_removeblocks in the
401     experiments/ directory, and type:
402     <p>
403     <pre>
404     $ <b>gunzip -c disk.img.gz | cp_removeblocks /dev/stdin disk.img</b>
405     </pre>
406    
407     <p>
408     This will give you a disk.img which looks like it is 9 GB, and works like
409     the real file, but the holes are not written out to the disk. (You can see
410     this by running for example <b>du disk.img</b> to see the physical block
411     count.)
412    
413    
414    
415     <p><br>
416     <a name="userland"></a>
417     <h3>Running userland binaries:</h3>
418    
419 dpavlin 42 <font color="#ff0000"><b>NOTE 2007-06-15:</b> I just removed most of the
420     userland (syscall) emulation support, and started a rewrite from scratch.
421     The rest of this section in the documentation is not currently valid.</font>
422 dpavlin 2
423 dpavlin 12 <p>There is some skeleton code for running userland programs as well. This
424     will not emulate any particular machine, but instead try to translate
425     syscalls from e.g. NetBSD/pmax into the host's OS' syscalls. Right now,
426     this is just a proof-of-concept, to show that it could work; there's lots
427     of work left to do to make it actually run useful programs.
428    
429 dpavlin 2 <p>
430    
431     <ul>
432     <li><b>NetBSD/pmax:</b>
433     <br>
434     Running /bin/hostname or /bin/date and similarly trivial
435     programs from the NetBSD/pmax distribution works:<pre>
436     $ <b>gxemul -q -u netbsd/pmax pmax_bin_hostname</b>
437     tab.csbnet.se
438     $ <b>gxemul -q -u netbsd/pmax pmax_bin_date</b>
439     Sun Jan 25 02:26:14 GMT 2004
440     $ <b>gxemul -q -u netbsd/pmax pmax_bin_sleep</b>
441     usage: pmax_bin_sleep seconds
442     $ <b>gxemul -q -u netbsd/pmax pmax_bin_sleep 5</b>
443     $ <b>gxemul -q -u netbsd/pmax pmax_bin_sync</b>
444     </pre>
445    
446     <p>
447     <li><b>Ultrix:</b>
448     <br>
449     At least /bin/date and /bin/hostname work:<pre>
450     $ <b>gxemul -q -u ultrix ultrix4_bin_date</b>
451     UNIMPLEMENTED ultrix syscall 54
452     UNIMPLEMENTED ultrix syscall 62
453     Mon Feb 9 12:50:59 WET 2004
454     $ <b>gxemul -q -u ultrix ultrix4_bin_hostname</b>
455     tab.csbnet.se
456     </pre>
457    
458 dpavlin 12 <!--
459 dpavlin 2 <p>
460     <li><b>NetBSD/powerpc:</b>
461     <br>
462     /bin/sync from NetBSD/macppc works, but probably not much else.<pre>
463     $ <b>gxemul -v -u netbsd/powerpc netbsd-1.6.2-macppc-bin-sync</b>
464     ...
465     [ sync() ]
466     [ exit(0) ]
467     cpu_run_deinit(): All CPUs halted.
468    
469     </pre>
470    
471     <p>
472     <li><b>Linux/PPC64:</b>
473     <br>
474     The <a href="http://www-106.ibm.com/developerworks/library/l-ppc/#h13">64-bit Hello World assembly language example</a>
475     on IBM's developerWorks pages runs:<pre>
476     $ <b>ppc64-unknown-linux-as hello-ppc64.s -o hello-ppc64.o</b>
477     $ <b>ppc64-unknown-linux-ld hello-ppc64.o -o hello-ppc64</b>
478     $ <b>gxemul -q -u linux/ppc64 hello-ppc64</b>
479     Hello, world!
480    
481     </pre>
482 dpavlin 12 -->
483 dpavlin 2
484     </ul>
485    
486    
487    
488    
489    
490     <p><br>
491     <a name="promdump"></a>
492     <h3>Using a PROM dump from a real machine:</h3>
493    
494     Raw PROM images from real machines can, in a few cases, be used in
495     the emulator. ROM code is usually much more sensitive to correctness
496     of the emulator than operating system kernels or userland programs
497     are, so don't expect any PROM image to just magically work.
498    
499    
500     <p>
501     <h4>Dumping the PROM on a DECstation 5000/125:</h4>
502     The image first needs to be extracted from the machine. There are
503     several ways to do this.
504     <ul>
505     <li>Use hardware to read the PROM chip(s) directly. Not easy if you
506     don't have such a hardware reader.
507     <li>Copy the PROM memory range into a file, from a running
508     operating system. You need a running OS, and it must
509     have access to the PROM memory range. NetBSD, for example,
510     doesn't allow that from userland.
511     <li>Hook up a serial console and dump using the PROM's own dump
512     command.
513     </ul>
514     <p>
515     The easiest way is to hook up a serial console. The terminal must be
516     able to capture output to a file.
517     <p>
518     These are approximately the commands that I used:
519     <pre>
520     >><b>cnfg</b> <i>Show machine configuration</i>
521    
522     >><b>printenv</b> <i>Show environment variables</i>
523    
524     >><b>setenv more 0</b> <i>This turns off the More messages</i>
525    
526     >><b>e -x 0xbfc00000:0xbfffffff</b> <i>Dump the PROM data</i>
527     </pre>
528     <p>
529     Remember that DECstations are little endian, so if the dump data
530     looks like this:
531     <pre>
532     bfc00000: 0x0bf0007e
533     </pre>
534     then the bytes in memory are actually 0x7e, 0x00, 0xf0, and 0x0b.
535     <p>
536     At 9600 bps, about 10KB can be dumped per minute, so it takes a while.
537     Once enough of the PROM has been dumped, you can press CTRL-C to break out.
538     Then, restore the more environment variable:
539     <pre>
540     >><b>setenv more 24</b>
541     </pre>
542     <p>
543     Now, convert the data you just saved (little-endian words -> bytes),
544     and store in a file. Let's call this file DECstation5000_125_promdump.bin.
545     <pre>
546     $ <b>decprom_dump_txt_to_bin DECstation5000_125_promdump.txt DECstation5000_125_promdump.bin</b>
547     </pre>
548     This binary image can now be used in the emulator:
549     <pre>
550 dpavlin 12 $ <b>gxemul -e 3min -Q -M128 -q 0xbfc00000:DECstation5000_125_promdump.bin</b>
551 dpavlin 2
552     KN02-BA V5.7e
553     ?TFL: 3/scc/access (1:Ln1 reg-12: actual=0x00 xpctd=0x01) [KN02-BA]
554     ?TFL: 3/scc/io (1:Ln0 tx bfr not empty. status=0X 0) [KN02-BA]
555     ...
556     --More--?TFL: 3/scsi/cntl (CUX, cause= 1000002C)
557     >><b>?</b>
558     ? [cmd]
559     boot [[-z #] [-n] #/path [ARG...]]
560     cat SCRPT
561     cnfg [#]
562     d [-bhw] [-S #] RNG VAL
563     e [-bhwcdoux] [-S #] RNG
564     erl [-c]
565     go [ADR]
566     init [#] [-m] [ARG...]
567     ls [#]
568     passwd [-c] [-s]
569     printenv [EVN]
570     restart
571     script SCRPT
572     setenv EVN STR
573     sh [-belvS] [SCRPT] [ARG..]
574     t [-l] #/STR [ARG..]
575     unsetenv EVN
576     >><b>cnfg</b>
577     3: KN02-BA DEC V5.7e TCF0 (128 MB)
578     (enet: 00-00-00-00-00-00)
579     (SCSI = 7)
580     0: PMAG-BA DEC V5.3a TCF0
581     >><b>printenv</b>
582     boot=
583     testaction=q
584     haltaction=h
585     more=24
586     #=3
587     console=*
588     osconsole=3
589     >>
590     </pre>
591 dpavlin 14
592     <p><font color="#ff0000">(Note: at the moment, this doesn't work.
593     I must have broken something when fixing something else, but this
594     is what it looked like at the time.)</font>
595    
596     <p>During bootup, the PROM complains <i>a lot</i> about hardware failures.
597 dpavlin 2 That's because the emulator doesn't emulate the hardware well enough yet.
598 dpavlin 14
599     <p>The command line options used are: <tt>-e 3min</tt> for
600     "DECstation 3min" (5000/1xx), <tt>-Q</tt> to supress the emulator's own PROM
601     call emulation, <tt>-M128</tt> for 128MB RAM (because GXemul doesn't correctly
602 dpavlin 2 emulate memory detection well enough for the PROM to accept, so it will
603 dpavlin 14 always believe there is 128MB ram anyway), and <tt>-q</tt> to supress debug messages.
604     The <tt>0xbfc00000</tt> in front of the filename tells GXemul that it is a raw
605 dpavlin 2 binary file which should be loaded at a specific virtual address.
606    
607    
608     <p><br>
609 dpavlin 42 <a name="promdump_o2"><h4>Dumping the PROM on a SGI O2:</h4></a>
610 dpavlin 2
611     The general ideas in this section applies to using ROM images from other
612 dpavlin 14 machines as well. I have also tried this on an SGI IP32 ("O2"), in addition
613     to the DECstation.
614    
615     <p>For the O2, a suitable command to dump the prom memory range is
616 dpavlin 2 <pre>
617     &gt;&gt; <b>dump -b 0xBFC00000:0xBFC80000</b>
618     </pre>
619     Make sure you capture all the output (via serial console) into a file,
620 dpavlin 14 and then run <tt>experiments/sgiprom_to_bin</tt> on the captured file.
621    
622 dpavlin 2 <p>
623 dpavlin 14 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
624     <a href="sgi-o2-real.jpg"><img src="sgi-o2-real_small.jpg"></a>
625     &nbsp;&nbsp;&nbsp;
626     <a href="20050817-sgi-o2-success-7.png"><img src="20050817-sgi-o2-success-7_small.png"></a>
627     &nbsp;&nbsp;&nbsp;
628     <a href="20050817-sgi-o2-success-8.png"><img src="20050817-sgi-o2-success-8_small.png"></a>
629 dpavlin 2
630 dpavlin 14 <p>The photo on the left is from the real machine. The other two are
631     screenshots of the PROM running experimentally in GXemul, using <tt>-Y2</tt>
632     framebuffer scaledown.
633 dpavlin 2
634 dpavlin 14 <p>Normally during bootup, the IP32 PROM does a Power-On test which makes
635     sure that the caches and other things are working properly. GXemul doesn't
636     emulate all those things well enough for the tests to pass. The
637     experimental screenshots above were taken with cache detection skipped
638     manually.
639 dpavlin 2
640 dpavlin 14 <p><font color="#ff0000">
641     In other words: don't expect this to work out-of-the-box with GXemul right
642     now. It might work once I've added correct cache emulation.</font>
643 dpavlin 2
644 dpavlin 14 <p>The command line used to start the emulator, once correct cache
645     emulation has been implemented, would be something like <tt>gxemul -XQeo2
646     0xbfc00000:prom.bin</tt>.
647 dpavlin 2
648 dpavlin 14 <p>The same caution applies when dealing with SGI PROMs as with
649     DECstation PROMs: GXemul doesn't really emulate the hardware, it only
650     "fakes" devices well enough to fool some things, primarily NetBSD, that
651     it is emulating a real machine. ROM code is usually a <i>lot</i> more
652     picky about the details.
653    
654     <p>The graphics used in the O2 is (as far as I know) undocumented. Combining
655     some traces of info from how Linux/O2 draws to the screen with some
656 dpavlin 18 reverse-engineering of my own, I've implemented enough of the controller to
657 dpavlin 14 let the PROM draw rectangles and bitmaps, but not much more. The SCSI
658     controller is not implemented yet either.
659    
660    
661    
662    
663 dpavlin 2 </p>
664    
665     </body>
666     </html>

  ViewVC Help
Powered by ViewVC 1.1.26