4 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
6 This directory contains the program PSIM that models the PowerPC(tm -
7 IBM) architecture. It can either be run stand alone (psim or run) or
14 SMP: A Symetric Multi-Processor configuration is suported. This
15 includes modeling of the PowerPC load word and reserve instructions
16 (if intending to use this feature you are well advised to read the the
17 source code for the reservation instructions so that you are aware of
18 any potential limitations in the model). The number of processors is
19 selected during startup.
21 DUAL-ENDIAN: Both little and big endian models are suported. The
22 execution of instruction sequences that switch between the two modes,
23 however, is not. The endianess is selected during startup.
25 UIEA, VEA and OEA: The PowerPC architecture defines three levels of
26 the PowerPC architecture. This simulator, to a reasonable degree, is
27 capable of modeling all three. That is the User Instruction Set
28 Architecture, the Virtual Environment Architecture and finally the
29 Operating Environment Architecture. The environment is selected
30 during startup. The OEA model is still under development.
32 HARDWARE DEVICE TREE: In the OEA, the model of the target machines
33 hardware is built from a tree of devices (bit like Open Boot).
34 Included in this is the ability to model bus hierachies and
35 runtime-configurable devices (eg PCI). The device tree used to create
36 the hardware model is created during startup. This device tree is
37 still under development.
39 VEA SYSTEM CALLS: In user mode, basic system calls (read, write, open,
40 close ...) are emulated. Under NetBSD (simply because that is what my
41 machine at home runs) the list is more extensive.
43 PEDANTIC VEA MEMORY MODEL: This model implements the break (brk, sbrk)
44 system calls. Further, the user model has very strict memory access
45 controls. User programs can not assume that they can stray off the
46 end of valid memory areas. This model defines valid memory addresses
47 in strict accordance to the executable and does not page allign their
48 values. At first this was a bug but since then has turned up several
49 problems in user code so it is now described as a feature.
51 PROFILING: The simulation is able to count the number and type of
52 instructions issued and the number of loads and stores. This feature
53 is still under development.
55 PERFORMANCE: In its default configuration PSIM is constructed so that
56 it will compile fast and run slow. Through the enabling of more
57 agressive compile options (and the disabling of unwanted features) the
58 build can be changed to compile slow and run fast.
60 FLOATING POINT: Preliminary suport for floating point is included.
61 Real kernels don't need floating point.
66 To build PSIM you will need the following:
68 gdb-4.15.tar.gz From your favorite GNU ftp site
70 ftp://ftp.ci.com.au/pub/clayton/gdb-4.15+psim-951016.diff.gz
72 This contains a few minor patches to
73 gdb-4.15 so that will include psim
76 ftp://ftp.ci.com.au/pub/clayton/gdb-4.15+psim-951016.tar.gz
78 This contains the psim files propper.
80 ftp://ftp.ci.com.au/pub/clayton/psim-test-951016.tar.gz
82 (Optional) A scattering of pre-compiled
83 programs that run under the simulator.
85 gcc Again available from your favorite
88 patch Sun's patch behaves a little wierd
89 and doesn't appear to like creating
93 In the directory ftp.ci.com.au:pub/clayton you will also notice files
94 named psim-NNNNNN.tar.gz. Those, more recent snapshots, may or may
101 gdb-4.15+psim-951016.diff.gz
102 gdb-4.15+psim-951016.tar.gz
104 psim-test-951016.tar.gz
109 $ gunzip < gdb-4.15.tar.gz | tar xf -
112 2. Change to the gdb directory, apply the psim patches and unpack
117 $ gunzip < ../gdb-4.15+psim-951016.diff.gz | more
118 $ gunzip < ../gdb-4.15+psim-951016.diff.gz | patch -p1
120 $ gunzip < ../gdb-4.15+psim-951016.tar.gz | tar tvf -
121 $ gunzip < ../gdb-4.15+psim-951016.tar.gz | tar xvf -
128 then something like (I assume SH):
130 $ CC=gcc ./configure --target=powerpc-unknown-eabisim
132 eabisim is needed as by default (because PSIM needs GCC) the
133 simulator is not built.
140 alternativly, if you are short on disk space or just want the
143 $ ( cd libiberty && make CC=gcc )
144 $ ( cd bfd && make CC=gcc )
145 $ ( cd sim/ppc && make CC=gcc )
150 $ make CC=gcc install
152 $ cp gdb/gdb ~/bin/powerpc-unknown-eabisim-gdb
153 $ cp sim/ppc/run ~/bin/powerpc-unknown-eabisim-run
158 (I assume that you've unpacked the psim-test archive).
160 1. As a standalone program
162 Print out the users environment:
164 $ powerpc-unknown-eabisim-run envp
166 Print out the arguments:
168 $ powerpc-unknown-eabisim-run argv a b c
170 Check that sbrk works:
172 $ powerpc-unknown-eabisim-run break
175 2. Example of running GDB:
177 The main thing to note is that before you can run the simulator
178 you must enable it. The example below illustrates this:
180 $ powerpc-unknown-eabisim-gdb envp
192 There is a mailing list (subscribe through majordomo@ci.com.au) (that
193 is almost never used) at:
195 powerpc-psim@ci.com.au
197 If I get the ftp archive updated I post a note to that news group. In
198 addition your welcome to send bugs or problems either to me or to that
204 See the ChangeLog file looking for lines taged with the word FIXME.
206 COREFILE.C: The implementation of corefile.c (defined by corefile.h) isn't the
207 best. It is intended to be functionaly correct rather than fast.
209 HTAB (page) code for OEA model untested. Some of the vm code
210 instructions unimplemented.
212 Flush instruction cache instructions do nothing. Perhaphs they should
213 (if there is an instruction cache) flush it.
215 Lacks PowerOpen (a.k.a. XCOFF a.k.a. AIX) and NT startups. The
216 PowerOpen worked until I added the ELF one.
218 OpenBoot and PR*P interfaces missing. Open boot could be implemented
219 by putting special instructions at the address of the OpenBoot
220 callback functions. Those instructions could than emulate OpenBoot
223 Missing VEA system calls.
225 Missing or commented out instructions.
227 64bit target untested.
229 64bit host broken. For instance use of scanf "%x", &long long.
231 Event code for pending events from within signal handlers not
234 Better and more devices.
236 PORTABILITY (Notes taken from Michael Meissner): Heavy use of the ##
237 operator - fix using the clasic X/**/Y hack; Use of the signed
238 keyword. In particular, signed char has no analogue in classic C
239 (though most implementations of classic C use signed chars); Use of
240 long long which restricts the target compiler to be GCC.
245 Thanks go to the following who each helped in some way.
247 Allen Briggs, Bett Koch, David Edelsohn, Gordon Irlam,
248 Michael Meissner, Bob Mercier, Richard Perini,
249 Richard Stallman, Mitchele Walker
252 ----------------------------------------------------------------
255 Random notes on performance:
259 time ../psim count `expr 10000000 / 2`
260 time ../psim volatile-count `expr 10000000 / 7`
262 Where 2 and 7 are the number of instructions in the main loop.
269 CFLAGS= -c -O2 -m486 -fomit-frame-pointer
271 o different first/second level table/switch combinations
274 1 - use a simple switch
275 2 - use an expanded switch
279 1/108/140 - switch=0/0/0,expand=2,inline=2,nia=1,cache=1
280 1/114/140 - switch=0/0/0,expand=2,inline=2,nia=1,cache=1
281 1/137/149 - switch=0/0,expand=2,inline=1,nia=1,cache=1
282 1/144/155 - switch=2/1,expand=2,inline=1,nia=1,cache=1
283 1/153/159 - switch=2/1,expand=0,inline=1,nia=1,cache=1
284 1/185/189 - switch=0/0,expand=0,inline=1,nia=1
288 1/572/695 - switch=1/1,expand=0,inline=0
289 1/579/729 - switch=0/0,expand=0,inline=0
290 1/570/682 - switch=2/2,expand=0,inline=0
291 1/431/492 - switch=0/0,expand=0,inline=1,nia=0
292 1/271/292 - switch=2/1,expand=0,inline=1,nia=0
293 1/270/316 - switch=2/2,expand=0,inline=1,nia=0
294 1/271/281 - switch=1/1,expand=0,inline=1,nia=1
295 1/267/274 - switch=2/1,expand=0,inline=1,nia=1