1 |
<html><head><title>Gavare's eXperimental Emulator: Experimenting with GXemul</title> |
2 |
<meta name="robots" content="noarchive,nofollow,noindex"></head> |
3 |
<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 |
<b>Gavare's eXperimental Emulator: </b></font> |
8 |
<font color="#000000" size="6"><b>Experimenting with GXemul</b> |
9 |
</font></td></tr></table></td></tr></table><p> |
10 |
|
11 |
<!-- |
12 |
|
13 |
$Id: experiments.html,v 1.92 2005/09/18 19:54:12 debug Exp $ |
14 |
|
15 |
Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
16 |
|
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 |
<a href="./">Back to the index</a> |
43 |
|
44 |
<p><br> |
45 |
<h2>Experimenting with GXemul</h2> |
46 |
|
47 |
<p> |
48 |
<ul> |
49 |
<li><a href="#hello">Hello world</a> |
50 |
<li><a href="#expdevices">Experimental devices</a> |
51 |
</ul> |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
<p><br> |
59 |
<a name="hello"></a> |
60 |
<h3>Hello world:</h3> |
61 |
|
62 |
You might want to use the emulator to develop programs on your own, |
63 |
not just run precompiled kernels such as NetBSD. To get started, I recommend |
64 |
that you do two things: |
65 |
|
66 |
<p> |
67 |
<ul> |
68 |
<li>Build and install a cross-compiler for MIPS. |
69 |
<li>Compile this hello world program, and run it in the emulator. |
70 |
</ul> |
71 |
|
72 |
<p> |
73 |
<table border="0"><tr><td width="40"> </td><td> |
74 |
<pre> |
75 |
<font color=#f00000>/* Hello world for GXemul */ |
76 |
|
77 |
/* Note: The cast to a signed int causes the address to be sign-extended |
78 |
correctly to 0xffffffffb00000xx when compiled in 64-bit mode */ |
79 |
</font><font color=#a0a0a0>#define PUTCHAR_ADDRESS ((signed int)0xb0000000) |
80 |
#define HALT_ADDRESS ((signed int)0xb0000010) |
81 |
|
82 |
</font><font color=#c000c0>void </font><font color=#000000><a name="printchar">printchar</a>(</font><font color=#c000c0>char </font><font color=#000000>ch) |
83 |
{ |
84 |
*((</font><font color=#c000c0>volatile unsigned char </font><font color=#000000>*) PUTCHAR_ADDRESS) = ch; |
85 |
} |
86 |
|
87 |
</font><font color=#c000c0>void </font><font color=#000000><a name="halt">halt</a>(</font><font color=#c000c0>void</font><font color=#000000>) |
88 |
{ |
89 |
*((</font><font color=#c000c0>volatile unsigned char </font><font color=#000000>*) HALT_ADDRESS) = 0; |
90 |
} |
91 |
|
92 |
</font><font color=#c000c0>void </font><font color=#000000><a name="printstr">printstr</a>(</font><font color=#c000c0>char </font><font color=#000000>*s) |
93 |
{ |
94 |
</font><font color=#c000c0>while </font><font color=#000000>(*s) |
95 |
printchar(*s++); |
96 |
} |
97 |
|
98 |
</font><font color=#c000c0>void </font><font color=#000000>f(</font><font color=#c000c0>void</font><font color=#000000>) |
99 |
{ |
100 |
printstr(</font><font color=#00c000>"Hello world\n"</font><font color=#000000>); |
101 |
halt(); |
102 |
} |
103 |
</font></pre> |
104 |
</td></tr></table> |
105 |
|
106 |
<p>(This hello world program is available here as well: |
107 |
<a href="hello_mips.c"><tt>hello_mips.c</tt></a>) |
108 |
|
109 |
<p>I recommend that you build a GCC cross compiler for the |
110 |
<b>mips64-unknown-elf</b> target, and install it. Other compilers could |
111 |
work too, but GCC is good because of its portability. Then try to compile |
112 |
and link the hello world program: |
113 |
<pre> |
114 |
$ <b>mips64-unknown-elf-gcc -O2 hello_mips.c -mips4 -mabi=64 -c</b> |
115 |
$ <b>mips64-unknown-elf-ld -Ttext 0xa800000000030000 -e f hello_mips.o -o hello_mips --oformat=elf64-bigmips</b> |
116 |
$ <b>file hello_mips</b> |
117 |
hello_mips: ELF 64-bit MSB mips-4 executable, MIPS R3000_BE, version 1 (SYSV), statically linked, not stripped |
118 |
$ <b>gxemul -q -E testmips hello_mips</b> |
119 |
Hello world |
120 |
|
121 |
$ <b>mips64-unknown-elf-gcc -O2 hello_mips.c -c</b> |
122 |
$ <b>mips64-unknown-elf-ld -Ttext 0x80030000 -e f hello_mips.o -o hello_mips</b> |
123 |
$ <b>file hello_mips</b> |
124 |
hello_mips: ELF 32-bit MSB mips-3 executable, MIPS R3000_BE, version 1 (SYSV), statically linked, not stripped |
125 |
$ <b>gxemul -q -E testmips hello_mips</b> |
126 |
Hello world |
127 |
</pre> |
128 |
|
129 |
<p> |
130 |
As you can see above, a GCC configured for mips64-unknown-elf can produce |
131 |
both 64-bit and 32-bit binaries. If you don't want to run the entire |
132 |
Hello World program, but want to single-step through the execution to |
133 |
learn more about how MIPS programs run, then add -V to the command line: |
134 |
|
135 |
<p> |
136 |
<pre> |
137 |
$ <b>gxemul -V -E testmips hello_mips</b> |
138 |
.. |
139 |
GXemul> <b>r</b> |
140 |
cpu0: pc = a800000000030078 <f> |
141 |
cpu0: hi = 0000000000000000 lo = 0000000000000000 |
142 |
cpu0: zr = 0000000000000000 at = 0000000000000000 |
143 |
cpu0: v0 = 0000000000000000 v1 = 0000000000000000 |
144 |
.. |
145 |
cpu0: gp = a8000000000780c0 sp = ffffffffa0007f00 |
146 |
cpu0: fp = 0000000000000000 ra = 0000000000000000 |
147 |
GXemul> <b>s 15</b> |
148 |
<f> |
149 |
a800000000030078: 67bdfff0 daddiu sp,sp,-16 |
150 |
a80000000003007c: 3c04a800 lui a0,0xa800 |
151 |
a800000000030080: 3c010003 lui at,0x3 |
152 |
a800000000030084: 64840000 daddiu a0,a0,0 |
153 |
a800000000030088: 642100b8 daddiu at,at,184 |
154 |
a80000000003008c: 0004203c dsll32 a0,a0,0 |
155 |
a800000000030090: 0081202d daddu a0,a0,at |
156 |
a800000000030094: ffbf0000 sd ra,0(sp) [0xffffffffa0007ef0, data=0x0000000000000000] |
157 |
a800000000030098: 0c00c00a jal 0xa800000000030028 <printstr> |
158 |
a80000000003009c: 00000000 (d) nop |
159 |
<printstr("Hello world\n",0,0,0,..)> |
160 |
<printstr> |
161 |
a800000000030028: 67bdfff0 daddiu sp,sp,-16 |
162 |
a80000000003002c: ffb00000 sd s0,0(sp) [0xffffffffa0007ee0, data=0x0000000000000000] |
163 |
a800000000030030: ffbf0008 sd ra,8(sp) [0xffffffffa0007ee8, data=0xa8000000000300a0] |
164 |
a800000000030034: 90820000 lbu v0,0(a0) [0xa8000000000300b8 = $LC0, data=0x48] |
165 |
a800000000030038: 00021600 sll v0,v0,24 |
166 |
GXemul> <b>print v0</b> |
167 |
v0 = 0x0000000048000000 |
168 |
GXemul> <b>_</b> |
169 |
</pre> |
170 |
|
171 |
<p>The syntax of the single-step debugger shouldn't be too hard to grasp. |
172 |
Type "<tt>s</tt>" to single-step one instruction. For some commands (e.g. |
173 |
the single-step command), just pressing enter on a blank line will cause |
174 |
the last command to be repeated. Type "<tt>quit</tt>" to quit. |
175 |
|
176 |
<p> |
177 |
Hopefully this is enough to get you inspired. :-) |
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
<p><br> |
185 |
<a name="expdevices"></a> |
186 |
<h3>Experimental devices:</h3> |
187 |
|
188 |
The emulator has several modes where it doesn't emulate any real machine. |
189 |
It can either run in "bare" mode, where no devices are included by default |
190 |
(just the CPU), or in a "test" mode where some simple devices are |
191 |
emulated. |
192 |
|
193 |
<p>The test machines (<tt>testmips</tt>, <tt>testppc</tt>, etc) have the |
194 |
following experimental devices: |
195 |
|
196 |
<p> |
197 |
<center><table border="0" width="80%"> |
198 |
|
199 |
<tr> |
200 |
<td align="left" valign="top" width="200"> |
201 |
<b><tt>cons</tt>:</b> |
202 |
<p>A simple console device, for writing |
203 |
characters to the controlling terminal |
204 |
and receiving keypresses. |
205 |
<p>Source code: <font color="#0000f0"><tt>src/devices/dev_cons.c</tt></font> |
206 |
<br>Default physical address:  <font color="#0000f0">0x10000000</font> |
207 |
</td> |
208 |
<td align="left" valign="top" width="25"> </td> |
209 |
<td align="left" valign="top"> |
210 |
<table border="0"> |
211 |
<tr> |
212 |
<td align="left" valign="top"><i><u>Offset:</u></i> </td> |
213 |
<td align="left" valign="top"><i><u>Effect:</u></i></td> |
214 |
</tr> |
215 |
<tr> |
216 |
<td align="left" valign="top"><tt>0x00</tt></td> |
217 |
<td align="left" valign="top"> |
218 |
Read: <b><tt>getchar()</tt></b> (non-blocking; returns |
219 |
<tt>0</tt> if no char was available)<br> |
220 |
Write: <b><tt>putchar(ch)</tt></b></td> |
221 |
</tr> |
222 |
<tr> |
223 |
<td align="left" valign="top"><tt>0x10</tt></td> |
224 |
<td align="left" valign="top">Read or write: <b><tt>halt()</tt></b><br> |
225 |
(Useful for exiting the emulator.)</td> |
226 |
</tr> |
227 |
</table> |
228 |
</td> |
229 |
</tr> |
230 |
|
231 |
<tr height="15"> |
232 |
<td height="15"> </td> |
233 |
</tr> |
234 |
|
235 |
<tr> |
236 |
<td align="left" valign="top"> |
237 |
<b><tt>mp</tt>:</b> |
238 |
<p>This device controls the behaviour of CPUs in an emulated |
239 |
multi-processor system. |
240 |
<p>Source code: <font color="#0000f0"><tt>src/devices/dev_mp.c</tt></font> |
241 |
<br>Default physical address:  <font color="#0000f0">0x11000000</font> |
242 |
</td> |
243 |
<td></td> |
244 |
<td align="left" valign="top"> |
245 |
<table border="0"> |
246 |
<tr> |
247 |
<td align="left" valign="top"><i><u>Offset:</u></i> </td> |
248 |
<td align="left" valign="top"><i><u>Effect:</u></i></td> |
249 |
</tr> |
250 |
<tr> |
251 |
<td align="left" valign="top"><tt>0x0000</tt></td> |
252 |
<td align="left" valign="top">Read: <b><tt>whoami()</tt></b>. |
253 |
Returns the id of the CPU doing the read.</td> |
254 |
</tr> |
255 |
<tr> |
256 |
<td align="left" valign="top"><tt>0x0010</tt></td> |
257 |
<td align="left" valign="top">Read: <b><tt>ncpus()</tt></b>. |
258 |
Returns the number of CPUs in the system.</td> |
259 |
</tr> |
260 |
<tr> |
261 |
<td align="left" valign="top"><tt>0x0020</tt></td> |
262 |
<td align="left" valign="top">Write: <b><tt>startupcpu(i)</tt></b>. |
263 |
Starts CPU i. It begins execution at the address |
264 |
set by a write to startupaddr (see below).</td> |
265 |
</tr> |
266 |
<tr> |
267 |
<td align="left" valign="top"><tt>0x0030</tt></td> |
268 |
<td align="left" valign="top">Write: <b><tt>startupaddr(addr)</tt></b>. |
269 |
Sets the starting address for CPUs.</td> |
270 |
</tr> |
271 |
<tr> |
272 |
<td align="left" valign="top"><tt>0x0040</tt></td> |
273 |
<td align="left" valign="top">Write: <b><tt>pause_addr(addr)</tt></b>. |
274 |
Sets the pause address. (TODO: This is not |
275 |
used anymore?)</td> |
276 |
</tr> |
277 |
<tr> |
278 |
<td align="left" valign="top"><tt>0x0050</tt></td> |
279 |
<td align="left" valign="top">Write: <b><tt>pause_cpu(i)</tt></b>. |
280 |
Stops all CPUs <i>except</i> CPU i.</td> |
281 |
</tr> |
282 |
<tr> |
283 |
<td align="left" valign="top"><tt>0x0060</tt></td> |
284 |
<td align="left" valign="top">Write: <b><tt>unpause_cpu(i)</tt></b>. |
285 |
Unpauses all CPUs <i>except</i> CPU i.</td> |
286 |
</tr> |
287 |
<tr> |
288 |
<td align="left" valign="top"><tt>0x0070</tt></td> |
289 |
<td align="left" valign="top">Write: <b><tt>startupstack(addr)</tt></b>. |
290 |
Sets the startup stack address. (CPUs started with |
291 |
startupcpu() above will have their stack pointer |
292 |
set to this value.)</td> |
293 |
</tr> |
294 |
<tr> |
295 |
<td align="left" valign="top"><tt>0x0080</tt></td> |
296 |
<td align="left" valign="top">Read: <b><tt>hardware_random()</tt></b>. |
297 |
This produces a "random" number.</td> |
298 |
</tr> |
299 |
<tr> |
300 |
<td align="left" valign="top"><tt>0x0090</tt></td> |
301 |
<td align="left" valign="top">Read: <b><tt>memory()</tt></b>. |
302 |
Returns the number of bytes of RAM in the system.</td> |
303 |
</tr> |
304 |
<tr> |
305 |
<td align="left" valign="top"><tt>0x00a0</tt></td> |
306 |
<td align="left" valign="top">Write: <b><tt>ipi_one((nr << 16) + cpuid)</tt></b>. |
307 |
Sends IPI <tt>nr</tt> to a specific CPU.</td> |
308 |
</tr> |
309 |
<tr> |
310 |
<td align="left" valign="top"><tt>0x00b0</tt></td> |
311 |
<td align="left" valign="top">Write: <b><tt>ipi_many((nr << 16) + cpuid)</tt></b>. |
312 |
Sends IPI <tt>nr</tt> to all CPUs <i>except</i> |
313 |
the specified one.</td> |
314 |
</tr> |
315 |
<tr> |
316 |
<td align="left" valign="top">0x00c0</tt></td> |
317 |
<td align="left" valign="top">Read: <b><tt>ipi_read()</tt></b>. |
318 |
Returns the next pending IPI. 0 is returned if there is no |
319 |
pending IPI (so 0 shouldn't be used for valid IPIs). |
320 |
Hardware int 6 is deasserted when the IPI queue is empty. |
321 |
<br>Write: <b><tt>ipi_flush()</tt></b>. |
322 |
Clears the IPI queue, discarding any pending IPIs.</td> |
323 |
</tr> |
324 |
<tr> |
325 |
<td align="left" valign="top">0x00d0</tt></td> |
326 |
<td align="left" valign="top">Read: <b><tt>ncycles()</tt></b>. |
327 |
Returns approximately the number of cycles executed. |
328 |
Note: this value is not updated for every instruction, |
329 |
so it cannot be used for small measurements.</td> |
330 |
</tr> |
331 |
</table> |
332 |
</td> |
333 |
</tr> |
334 |
|
335 |
<tr height="15"> |
336 |
<td height="15"> </td> |
337 |
</tr> |
338 |
|
339 |
<tr> |
340 |
<td align="left" valign="top"> |
341 |
<b><tt>fb</tt>:</b> |
342 |
<p>A simple linear framebuffer, for graphics output. |
343 |
640 x 480 pixels, 3 bytes per pixel (red, green, blue, 8 bits each). |
344 |
<p>Source code: <font color="#0000f0"><tt>src/devices/dev_fb.c</tt></font> |
345 |
<br>Default physical address:  <font color="#0000f0">0x12000000</font> |
346 |
</td> |
347 |
<td></td> |
348 |
<td align="left" valign="top"> |
349 |
<table border="0"> |
350 |
<tr> |
351 |
<td align="left" valign="top"><i><u>Offset:</u></i> </td> |
352 |
<td align="left" valign="top"><i><u>Effect:</u></i></td> |
353 |
</tr> |
354 |
<tr> |
355 |
<td align="left" valign="top"><tt>0x00000-</tt><br><tt>0xe0fff</tt></td> |
356 |
<td align="left" valign="top">Read: read pixel values. |
357 |
<br>Write: write pixel values.</td> |
358 |
</tr> |
359 |
</table> |
360 |
</td> |
361 |
</tr> |
362 |
|
363 |
<tr height="15"> |
364 |
<td height="15"> </td> |
365 |
</tr> |
366 |
|
367 |
<tr> |
368 |
<td align="left" valign="top"> |
369 |
<b><tt>disk</tt>:</b> |
370 |
<p>Disk controller, which can read from and write |
371 |
to disk images. It does not use interrupts; read and |
372 |
write operations finish instantaneously. |
373 |
<p>Source code: <font color="#0000f0"><tt>src/devices/dev_disk.c</tt></font> |
374 |
<br>Default physical address:  <font color="#0000f0">0x13000000</font> |
375 |
</td> |
376 |
<td></td> |
377 |
<td align="left" valign="top"> |
378 |
<table border="0"> |
379 |
<tr> |
380 |
<td align="left" valign="top"><i><u>Offset:</u></i> </td> |
381 |
<td align="left" valign="top"><i><u>Effect:</u></i></td> |
382 |
</tr> |
383 |
<tr> |
384 |
<td align="left" valign="top"><tt>0x0000</tt></td> |
385 |
<td align="left" valign="top">Write: Set the offset (in bytes) from the beginning |
386 |
of the disk image. This offset will be used for the next read/write operation.</td> |
387 |
</tr> |
388 |
<tr> |
389 |
<td align="left" valign="top"><tt>0x0010</tt></td> |
390 |
<td align="left" valign="top">Write: Select the SCSI ID to be used in the next |
391 |
read/write operation.</td> |
392 |
</tr> |
393 |
<tr> |
394 |
<td align="left" valign="top"><tt>0x0020</tt></td> |
395 |
<td align="left" valign="top">Write: Start a read or write operation. |
396 |
(Writing <tt>0</tt> means a Read operation, a <tt>1</tt> means a |
397 |
Write operation.)</td> |
398 |
</tr> |
399 |
<tr> |
400 |
<td align="left" valign="top"><tt>0x0030</tt></td> |
401 |
<td align="left" valign="top">Read: Get status of the last operation. |
402 |
(Status 0 means failure, non-zero means success.)</td> |
403 |
</tr> |
404 |
<tr> |
405 |
<td align="left" valign="top"><tt>0x4000-</tt><br><tt>0x41ff</tt> </td> |
406 |
<td align="left" valign="top">Read/Write: 512 bytes data buffer.</td> |
407 |
</tr> |
408 |
</table> |
409 |
</td> |
410 |
</tr> |
411 |
|
412 |
<tr height="15"> |
413 |
<td height="15"> </td> |
414 |
</tr> |
415 |
|
416 |
<tr> |
417 |
<td align="left" valign="top"> |
418 |
<b><tt>ether</tt>:</b> |
419 |
<p>A simple ethernet controller, enough to send |
420 |
and receive packets on a simulated network. |
421 |
<p>Source code: <font color="#0000f0"><tt>src/devices/dev_ether.c</tt></font> |
422 |
<br>Default physical address:  <font color="#0000f0">0x14000000</font> |
423 |
</td> |
424 |
<td></td> |
425 |
<td align="left" valign="top"> |
426 |
<table border="0"> |
427 |
<tr> |
428 |
<td align="left" valign="top"><i><u>Offset:</u></i> </td> |
429 |
<td align="left" valign="top"><i><u>Effect:</u></i></td> |
430 |
</tr> |
431 |
<tr> |
432 |
<td align="left" valign="top"><tt>0x0000-</tt><br><tt>0x3fff</tt></td> |
433 |
<td align="left" valign="top">Read/write buffer for the packet to be sent/received.</td> |
434 |
</tr> |
435 |
<tr> |
436 |
<td align="left" valign="top"><tt>0x4000</tt></td> |
437 |
<td align="left" valign="top">Read: status word, one or more of these: |
438 |
<br><tt>0x01</tt> = something was received (because of |
439 |
the last command) |
440 |
<br><tt>0x02</tt> = more packets are available |
441 |
<br><i>NOTE:</i> Whenever the status word is non-zero, |
442 |
an interrupt is asserted. Reading the status word |
443 |
clears it, and deasserts the interrupt.</td> |
444 |
</tr> |
445 |
<tr> |
446 |
<td align="left" valign="top"><tt>0x4010</tt></td> |
447 |
<td align="left" valign="top">Read: get the Length of the received packet |
448 |
<br>Write: set the Length of the next packet to transmit</td> |
449 |
</tr> |
450 |
<tr> |
451 |
<td align="left" valign="top"><tt>0x4020</tt></td> |
452 |
<td align="left" valign="top">Write: command: |
453 |
<br><tt>0x00:</tt> receive a packet |
454 |
<br><tt>0x01:</tt> send a packet</td> |
455 |
</tr> |
456 |
</table> |
457 |
</td> |
458 |
</tr> |
459 |
|
460 |
</table></center> |
461 |
|
462 |
<p> |
463 |
While these devices may resemble real-world hardware, they are |
464 |
intentionally made simpler to use. (An exception is the framebuffer; |
465 |
some machines actually have simple linear framebuffers like this.) |
466 |
|
467 |
<p>If the physical address is <tt>0x10000000</tt>, then for MIPS that |
468 |
means that it can be accessed at virtual address |
469 |
<tt>0xffffffffb0000000</tt>. (Actually it can be accessed at |
470 |
<tt>0xffffffff90000000</tt> too, but devices should usually be accessed in |
471 |
a non-cached manner.) |
472 |
|
473 |
<p> (When using the PPC test machine (<tt>testppc</tt>), the addresses are |
474 |
<tt>0x10000000</tt>, <tt>0x11000000</tt> etc., so no need to add any |
475 |
virtual displacement.) |
476 |
|
477 |
<p>The <b><tt>mp</tt></b>, <b><tt>disk</tt></b>, and <b><tt>ether</tt></b> |
478 |
devices are agnostic when it comes to word-length. For example, when |
479 |
reading offset <tt>0x0000</tt> of the <b><tt>mp</tt></b> |
480 |
device, you may use any kind of read (an 8-bit read will work just as well |
481 |
as a 64-bit read, although the value will be truncated to 8 bits in the |
482 |
first case). You can <i>not</i>, however, read one byte from <tt>0x0000</tt> |
483 |
and one from <tt>0x0001</tt>, and combine the result. The read from |
484 |
<tt>0x0001</tt> will be invalid. |
485 |
|
486 |
<p>The <b><tt>cons</tt></b> device should be accessed using 8-bit reads |
487 |
and writes. Doing a getchar() (ie reading from offset <tt>0x00</tt>) |
488 |
returns <tt>0</tt> if no character was available. |
489 |
|
490 |
<p>On MIPS, the <b><tt>cons</tt></b> device is hardwired to interrupt 2 |
491 |
(the lowest hardware interrupt). Whenever a character is available, the |
492 |
interrupt is asserted. When there are no more available characters, the |
493 |
interrupt is deasserted. (Remember that the interrupt has to be enabled in |
494 |
the status register of the system coprocessor.) |
495 |
|
496 |
<p>The <b><tt>ether</tt></b> device is hardwired to interrupt 3. |
497 |
|
498 |
<p>The IPIs controlled by the <b><tt>mp</tt></b> device are hardwired to |
499 |
interrupt 6. Whenever an IPI is "sent", interrupt 6 is asserted on the |
500 |
target CPU(s), and the IPI number is added last in the IPI queue for that |
501 |
CPU. It is then up to that CPU to read from offset <tt>0x00c0</tt>, to |
502 |
figure out what kind of IPI it was. |
503 |
|
504 |
<p>A simple tutorial on how to use the <tt>disk</tt> device, if not clear |
505 |
from the description above, can be found here: <a |
506 |
href="test_disk.c"><tt>test_disk.c</tt></a> |
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
<!-- |
517 |
|
518 |
<li><a href="http://www-2.cs.cmu.edu/afs/cs/project/mach/public/www/mach.html">Mach</a>: |
519 |
<br>Important! Run <b><tt>./configure --caches; make</tt></b> |
520 |
<br>Also important: This is broken right now. :-( |
521 |
<br>Download <a href="http://lost-contact.mit.edu/afs/athena/user/d/a/daveg/Info/Links/Mach/src/release/">http://lost-contact.mit.edu/afs/athena/user/d/a/daveg/Info/Links/Mach/src/release</a>/<a href="http://lost-contact.mit.edu/afs/athena/user/d/a/daveg/Info/Links/Mach/src/release/pmax.tar.Z">pmax.tar.Z</a> |
522 |
<br><tt><b>tar xfvz pmax.tar.Z pmax_mach/special/mach.boot.MK83.STD+ANY</b></tt> |
523 |
<br><tt><b>gxemul -e 3max -X pmax_mach/special/mach.boot.MK83.STD+ANY</b></tt> |
524 |
</ul> |
525 |
</li> |
526 |
|
527 |
<p> |
528 |
|
529 |
<li>SGI: |
530 |
<li>Linux/SGI: |
531 |
<br>Some kernels are available here: <a href="http://www.linux-mips.org/~glaurung/">http://www.linux-mips.org/~glaurung/</a> |
532 |
<br>Try running with <b><tt>-e ip32 -X</tt></b> for a graphical framebuffer, or |
533 |
<b><tt>-e ip32 -o 'console=ttyS0'</tt></b> for serial console. |
534 |
<br>Adding <b><tt>-b</tt></b> (bintrans) might work sometimes. |
535 |
<br>(You need to add <b><tt>-CR5000</tt></b> if you're trying to run |
536 |
a kernel compiled for R5000, because Linux doesn't autodetect |
537 |
the CPU type at runtime.) |
538 |
<br>Also: <a href="http://www.tal.org/~milang/o2/kernels/">http://www.tal.org/~milang/o2/kernels</a>/<a href="http://home.tal.org/~milang/o2/kernels/vmlinux64-2.6.8.1-IP32">vmlinux64-2.6.8.1-IP32</a> |
539 |
<br>Try <b><tt>-e ip32 -X -CR5000 vmlinux64-2.6.8.1-IP32</tt></b>. |
540 |
<br>And also some IP27 kernels: |
541 |
<a href="http://www.total-knowledge.com/progs/mips/kernels/vmlinux.ip27-20040428">http://www.total-knowledge.com/progs/mips/kernels/vmlinux.ip27-20040428</a> |
542 |
and |
543 |
<a href="http://www.total-knowledge.com/progs/mips/kernels/vmlinux.ip27-20040528.bz2">http://www.total-knowledge.com/progs/mips/kernels/vmlinux.ip27-20040528.bz2</a> |
544 |
(but unfortunately these lack symbols). |
545 |
<br>Try the IP27 kernels with <b><tt>-e ip27 -t</tt></b>. |
546 |
<p> |
547 |
<li><a href="http://www.openbsd.org/sgi.html">OpenBSD/sgi</a>: |
548 |
<br><a href="ftp://ftp.openbsd.org/pub/OpenBSD/3.7/sgi/bsd.rd">ftp://ftp.openbsd.org/pub/OpenBSD/3.7/sgi/bsd.rd</a> |
549 |
<br>More recent snapshots can be found at <a href="ftp://ftp.OpenBSD.org/pub/OpenBSD/snapshots/sgi/">ftp://ftp.OpenBSD.org/pub/OpenBSD/snapshots/sgi/</a>. |
550 |
<br>Try <b><tt>gxemul -e ip32 bsd.rd</tt></b> |
551 |
<p> |
552 |
<li><a href="http://www.freebsd.org/platforms/mips.html">FreeBSD/MIPS</a>: |
553 |
I don't think public binary snapshots are available yet. |
554 |
<p> |
555 |
<li>arcdiag: |
556 |
<br>The NetBSD people have also made available an "arcdiag" for SGI-IP22: |
557 |
<br><a href="ftp://ftp.netbsd.org/pub/NetBSD/arch/sgimips/arcdiag.ip22">ftp://ftp.netbsd.org/pub/NetBSD/arch/sgimips/arcdiag.ip22</a> |
558 |
<br>Try running <tt><b>gxemul -e ip22 -x arcdiag.ip22</b></tt>. |
559 |
</ul> |
560 |
</li> |
561 |
|
562 |
|
563 |
<li>ARC: |
564 |
<li>Linux: |
565 |
<br><a href="ftp://ftp.linux-mips.org/pub/linux/mips/mipsel-linux/boot/vmlinux-m700-2.1.131.gz">ftp://ftp.linux-mips.org/pub/linux/mips/mipsel-linux/boot/vmlinux-m700-2.1.131.gz</a> |
566 |
<br>gunzip, and run with <b><tt>-v -J -X -N -e m700</tt></b> (Olivetti M700) |
567 |
<br>(This probably doesn't work anymore.) |
568 |
<p> |
569 |
<li>Pandora: |
570 |
<br><a href="ftp://ftp.linux-mips.org/pub/linux/mips/ancient/milo/">ftp://ftp.linux-mips.org/pub/linux/mips/ancient/milo</a>/<a href="ftp://ftp.linux-mips.org/pub/linux/mips/ancient/milo/milo-0.27.1.tar.gz">milo-0.27.1.tar.gz</a> |
571 |
<br>A generic test/diagnostics program for ARC-based machines. |
572 |
<br>Run with <b><tt>-e r94 milo-0.27.1/pandora</tt></b> |
573 |
<p> |
574 |
<li>arcdiag: |
575 |
<br>Precompiled binary:<a href="ftp://ftp.netbsd.org/pub/NetBSD/arch/arc/arcdiag">ftp://ftp.netbsd.org/pub/NetBSD/arch/arc/arcdiag</a> |
576 |
<br>(alternative: <a href="http://www.sensi.org/~alec/mips/arcdiag">http://www.sensi.org/~alec/mips/arcdiag</a>) |
577 |
<br>A generic test/diagnostics program for ARC-based machines. |
578 |
<br>Run with <b><tt>-e pica arcdiag</tt></b> (or some other ARC mode). |
579 |
<br>Example arcdiag output (from real machines): |
580 |
<br><a href="http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html">http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html</a> (Olivetti M700-10) |
581 |
<br><a href="http://www.sensi.org/~alec/mips/arcdiag.txt">http://www.sensi.org/~alec/mips/arcdiag.txt</a> (PICA-61) |
582 |
<br><a href="http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html">http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html</a> (Deskstation Tyne) |
583 |
<br><a href="http://mail-index.netbsd.org/port-arc/2004/02/01/0001.html">http://mail-index.netbsd.org/port-arc/2004/02/01/0001.html</a> (NEC RISCserver 4200) |
584 |
<br><a href="http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out">http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out</a> (NEC-R96) |
585 |
<br>For some machines, such as <tt><b>-e pica</b></tt>, you can |
586 |
add <b><tt>-X</tt></b> to boot with a graphical VGA-style |
587 |
console. This however is probably a bit unstable and/or |
588 |
broken right now. |
589 |
<p> |
590 |
<li>Windows NT: |
591 |
<br>Put a "Windows NT 4.0 for MIPS" CDROM (or similar) into |
592 |
your CDROM drive. (On FreeBSD systems, it is usually called |
593 |
/dev/cd0c or similar. Change that to whatever the CDROM |
594 |
is called on your system, or the name of a raw .iso image.) |
595 |
<br>I have tried this with the Swedish version, but it might |
596 |
work with other versions too.<pre> |
597 |
$ <b><tt>dd if=/dev/zero of=winnt_test.img bs=1024 count=1 seek=999000</tt></b> |
598 |
$ <b><tt>gxemul -X -e pica -d winnt_test.img -d bc6:/dev/cd0c -j MIPS\\ARCINST</tt></b> |
599 |
$ <b><tt>gxemul -X -e pica -d winnt_test.img -d bc6:/dev/cd0c -j MIPS\\SETUPLDR</tt></b> |
600 |
</pre> <br><tt>ARCINST</tt> tries to prepare the disk image for installation. (It <i>almost</i> works.) |
601 |
<br><tt>SETUPLDR</tt> should load some drivers from the cdrom, but then it crashes with a bluescreen. |
602 |
</ul> |
603 |
</li> |
604 |
|
605 |
<p> |
606 |
|
607 |
<li>HPCmips: |
608 |
<li>Linux for BE300: |
609 |
<br><a href="http://www.linux4.be/2004/linux4be20040908.zip">http://www.linux4.be/2004/linux4be20040908.zip</a> |
610 |
<br>Try <b><tt>gxemul -X -e be300 vmlinux</tt></b> |
611 |
<p> |
612 |
<li>Linux for Agenda VR3: |
613 |
<br>Download <a href="http://agenda-snow.sourceforge.net/kernel-old-versions/binary/">http://agenda-snow.sourceforge.net/kernel-old-versions/binary</a>/<a href="http://agenda-snow.sourceforge.net/kernel-old-versions/binary/root1.2.6.kernel-8.00">root1.2.6.kernel-8.00</a> |
614 |
<br>and <a href="http://vr3.uid0.sk/cd/Software/VR3_Distributions/H2O/">http://vr3.uid0.sk/cd/Software/VR3_Distributions/H2O</a>/<a href="http://vr3.uid0.sk/cd/Software/VR3_Distributions/H2O/root1.2.6.cramfs">root1.2.6.cramfs</a>. |
615 |
<br>(or <a href="http://www.ipsec.info/~www/agenda/dream-1-noxip.cramfs">http://www.ipsec.info/~www/agenda/dream-1-noxip.cramfs</a>) |
616 |
<br>Try <b><tt>gxemul -X -e vr3 -x 0xbf200000:root1.2.6.cramfs 0xbf000000:0:0xbf0005e0:root1.2.6.kernel-8.00</tt></b> |
617 |
<br>(or replace root1.2.6.cramfs with dream-1-noxip.cramfs) |
618 |
<br>Remove <b><tt>-X</tt></b> to try with serial console instead of X, and |
619 |
remove <b><tt>-b</tt></b> to try without (old) bintrans. |
620 |
<br>Add <b><tt>-o 'init=/bin/sh'</tt></b> to boot into a single-user shell. |
621 |
<br>Add <b><tt>-o 'init=/sbin/restore_defaults'</tt></b> to run |
622 |
a <tt>/sbin/restore_defaults</tt> (attempt to initialize the |
623 |
flash memory). |
624 |
<p> |
625 |
<li>Linux for MobilePro etc.: |
626 |
<br><a href="http://pc1.peanuts.gr.jp/~kei/Hard-Float/Kernels/">http://pc1.peanuts.gr.jp/~kei/Hard-Float/Kernels/</a> |
627 |
<br>Uncompress the archive to get a kernel, vmlinux-800 for example. |
628 |
<br>Try <b><tt>./gxemul -X -o 'root=/dev/hda1' -d r:disk.img -d r:disk.img -e mobilepro800 vmlinux-800</tt></b> |
629 |
<br>where disk.img is an ext2fs filesystem with contents from |
630 |
<a href="http://pc1.peanuts.gr.jp/~kei/Hard-Float/Miniroots/miniroot-20010330.tar.bz2">http://pc1.peanuts.gr.jp/~kei/Hard-Float/Miniroots/miniroot-20010330.tar.bz2</a> |
631 |
<br>(Note the double disk arguments.) |
632 |
<br>Note 2: This doesn't work yet. |
633 |
<p> |
634 |
<li><a href="http://www.disorder.ru/openbsd/be300/">OpenBSD/be300</a>: |
635 |
<br><a href="http://www.disorder.ru/openbsd/be300/bsd.rd">http://www.disorder.ru/openbsd/be300/bsd.rd</a> |
636 |
<br>Try <b><tt>gxemul -X -e be300 bsd.rd</tt></b> |
637 |
<br>Note: bintrans might be buggy, so you can try with -B if you want to. |
638 |
</ul> |
639 |
</li> |
640 |
|
641 |
<p> |
642 |
|
643 |
<li>Linux: |
644 |
<br><a href="http://people.debian.org/~pm/mips-cobalt/nfsroot/vmlinux_raq-2800.gz">http://people.debian.org/~pm/mips-cobalt/nfsroot/vmlinux_raq-2800.gz</a> |
645 |
<br>gunzip, and run with <b><tt>-E cobalt</tt></b> |
646 |
<p> |
647 |
<br><a href="http://dev.gentoo.org/~kumba/mips/cobalt/netboot/cobalt-netboot-20040428.img.gz">http://dev.gentoo.org/~kumba/mips/</a> |
648 |
<br> <a href="http://dev.gentoo.org/~kumba/mips/cobalt/netboot/cobalt-netboot-20040428.img.gz">cobalt/netboot/cobalt-netboot-20040428.img.gz</a> |
649 |
<br><b><tt>gxemul -E cobalt cobalt-netboot-20040428.img.gz</tt></b> |
650 |
<p> |
651 |
<li>CoLo: |
652 |
<br><a href="http://www.colonel-panic.org/cobalt-mips/colo/colo-1.19.tar.gz">http://www.colonel-panic.org/cobalt-mips/colo/colo-1.19.tar.gz</a> |
653 |
<br><tt><b>tar zxvf colo-1.19.tar.gz colo-1.19/binaries/colo-rom-image.bin</b></tt> |
654 |
<br><tt><b>gxemul -Q -Ecobalt -v 0xbfc00000:colo-1.19/binaries/colo-rom-image.bin</b></tt> |
655 |
<br>(This doesn't work yet.) |
656 |
|
657 |
<p> |
658 |
<li>Linux: |
659 |
<br>A Linux kernel (2.2.21-pre1-xr7) is available from |
660 |
<a href="http://playstation2-linux.com/projects/xrhino-kernel/">http://playstation2-linux.com/projects/xrhino-kernel/</a> |
661 |
<br>Try running with <b><tt>-X -E playstation2</tt></b> (<b><tt>-X</tt></b> is required, for the framebuffer). |
662 |
</ul> |
663 |
</li> |
664 |
|
665 |
<p> |
666 |
|
667 |
|
668 |
|
669 |
meshcube Linux: |
670 |
<br>A Linux kernel is available from |
671 |
<a href="http://www.meshcube.org/feed/stable/">http://www.meshcube.org/feed/stable</a>/<a href="http://www.meshcube.org/feed/stable/kernel-image-mtx_2.4.24-3_mipsel.ipk">kernel-image-mtx_2.4.24-3_mipsel.ipk</a> |
672 |
<br>(This is a Debian package, you can use <tt><b>ar</b></tt> and |
673 |
<tt><b>tar</b></tt> to extract kernel.img from it.) |
674 |
<br>Try running with <b><tt>-E meshcube 0x80800000:kernel.img</tt></b>. |
675 |
|
676 |
<li><a href="http://www.seattlewireless.net/index.cgi/NetgearWG602">NetGear WG602</a>: |
677 |
<li>Linux: |
678 |
<br>A Linux kernel is available from |
679 |
<a href="ftp://downloads.netgear.com/files/wg602_v1715.zip">ftp://downloads.netgear.com/files/wg602_v1715.zip</a> |
680 |
<br>(Unzip wg602_v1715.zip to get WG602_V1715.img.) |
681 |
<br>Try running with <b><tt>-E netgear 0xbfc80000:0x40:WG602_V1715.img</tt></b>. |
682 |
<br>(It takes some time to decompress the kernel, so be patient.) |
683 |
<br>(This doesn't really work yet.) |
684 |
|
685 |
|
686 |
<li>Linux: |
687 |
<br><a href="http://jocelyn.mayer.free.fr/qemu-ppc/linux_images/2.4.25-PPC/vmlinux">http://jocelyn.mayer.free.fr/qemu-ppc/linux_images/2.4.25-PPC/vmlinux</a> |
688 |
<br><tt><b>gxemul -E prep -v -t vmlinux</b></tt> |
689 |
|
690 |
<li><a href="http://www.bebox.nu/os.php?s=os/linux/index">Linux/bebox</a>: |
691 |
<br><a href="http://www.bebox.nu/files/linux/BeBox-scsi-980610.gz">http://www.bebox.nu/files/linux/BeBox-scsi-980610.gz</a> |
692 |
<br><tt><b>gunzip BeBox-scsi-980610.gz</b></tt> |
693 |
<br><tt><b>gxemul -E bebox 0x3100:0x400:BeBox-scsi-980610</b></tt> |
694 |
|
695 |
--> |
696 |
|
697 |
|
698 |
|
699 |
|
700 |
</p> |
701 |
|
702 |
</body> |
703 |
</html> |