Add determining when we do not have enough writeback slots; Do not do model specific...
[deliverable/binutils-gdb.git] / sim / ppc / README.psim
1
2 PSIM
3
4 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
5
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
8 used as part of GDB.
9
10
11 KNOWN FEATURES
12
13
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.
20
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.
24
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.
31
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.
38
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.
42
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.
50
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.
54
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.
59
60 FLOATING POINT: Preliminary suport for floating point is included.
61 Real kernels don't need floating point.
62
63
64 BUILDING PSIM:
65
66 To build PSIM you will need the following:
67
68 gdb-4.15.tar.gz From your favorite GNU ftp site
69
70 ftp://ftp.ci.com.au/pub/clayton/gdb-4.15+psim-951016.diff.gz
71
72 This contains a few minor patches to
73 gdb-4.15 so that will include psim
74 when it is built.
75
76 ftp://ftp.ci.com.au/pub/clayton/gdb-4.15+psim-951016.tar.gz
77
78 This contains the psim files propper.
79
80 ftp://ftp.ci.com.au/pub/clayton/psim-test-951016.tar.gz
81
82 (Optional) A scattering of pre-compiled
83 programs that run under the simulator.
84
85 gcc Again available from your favorite
86 GNU ftp site.
87
88 patch Sun's patch behaves a little wierd
89 and doesn't appear to like creating
90 empty files.
91
92
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
95 not work with gdb.
96
97
98 0. A starting point
99
100 $ ls -1
101 gdb-4.15+psim-951016.diff.gz
102 gdb-4.15+psim-951016.tar.gz
103 gdb-4.15.tar.gz
104 psim-test-951016.tar.gz
105
106
107 1. Unpack gdb
108
109 $ gunzip < gdb-4.15.tar.gz | tar xf -
110
111
112 2. Change to the gdb directory, apply the psim patches and unpack
113 the psim files.
114
115 $ cd gdb-4.15
116
117 $ gunzip < ../gdb-4.15+psim-951016.diff.gz | more
118 $ gunzip < ../gdb-4.15+psim-951016.diff.gz | patch -p1
119
120 $ gunzip < ../gdb-4.15+psim-951016.tar.gz | tar tvf -
121 $ gunzip < ../gdb-4.15+psim-951016.tar.gz | tar xvf -
122
123
124 3. Configure gdb
125
126 $ more gdb/README
127
128 then something like (I assume SH):
129
130 $ CC=gcc ./configure --target=powerpc-unknown-eabisim
131
132 eabisim is needed as by default (because PSIM needs GCC) the
133 simulator is not built.
134
135
136 4. Build
137
138 $ make CC=gcc
139
140 alternativly, if you are short on disk space or just want the
141 simulator built:
142
143 $ ( cd libiberty && make CC=gcc )
144 $ ( cd bfd && make CC=gcc )
145 $ ( cd sim/ppc && make CC=gcc )
146
147
148 5. Install
149
150 $ make CC=gcc install
151 or just
152 $ cp gdb/gdb ~/bin/powerpc-unknown-eabisim-gdb
153 $ cp sim/ppc/run ~/bin/powerpc-unknown-eabisim-run
154
155
156 USING THE SIMULATOR:
157
158 (I assume that you've unpacked the psim-test archive).
159
160 1. As a standalone program
161
162 Print out the users environment:
163
164 $ powerpc-unknown-eabisim-run envp
165
166 Print out the arguments:
167
168 $ powerpc-unknown-eabisim-run argv a b c
169
170 Check that sbrk works:
171
172 $ powerpc-unknown-eabisim-run break
173
174
175 2. Example of running GDB:
176
177 The main thing to note is that before you can run the simulator
178 you must enable it. The example below illustrates this:
179
180 $ powerpc-unknown-eabisim-gdb envp
181 (gdb) target sim
182 (gdb) load
183 (gdb) break main
184 (gdb) run
185 .
186 .
187 .
188
189
190 BUGS AND PROBLEMS:
191
192 There is a mailing list (subscribe through majordomo@ci.com.au) (that
193 is almost never used) at:
194
195 powerpc-psim@ci.com.au
196
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
199 e-mail list.
200
201
202 KNOWN PROBLEMS:
203
204 See the ChangeLog file looking for lines taged with the word FIXME.
205
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.
208
209 HTAB (page) code for OEA model untested. Some of the vm code
210 instructions unimplemented.
211
212 Flush instruction cache instructions do nothing. Perhaphs they should
213 (if there is an instruction cache) flush it.
214
215 Lacks PowerOpen (a.k.a. XCOFF a.k.a. AIX) and NT startups. The
216 PowerOpen worked until I added the ELF one.
217
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
221 behavour.
222
223 Missing VEA system calls.
224
225 Missing or commented out instructions.
226
227 64bit target untested.
228
229 64bit host broken. For instance use of scanf "%x", &long long.
230
231 Event code for pending events from within signal handlers not
232 finished/tested.
233
234 Better and more devices.
235
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.
241
242
243 THANKS:
244
245 Thanks go to the following who each helped in some way.
246
247 Allen Briggs, Bett Koch, David Edelsohn, Gordon Irlam,
248 Michael Meissner, Bob Mercier, Richard Perini,
249 Richard Stallman, Mitchele Walker
250
251
252 ----------------------------------------------------------------
253
254
255 Random notes on performance:
256
257
258 $ cd test
259 time ../psim count `expr 10000000 / 2`
260 time ../psim volatile-count `expr 10000000 / 7`
261
262 Where 2 and 7 are the number of instructions in the main loop.
263
264
265 611/729 - baseline
266
267 Tests:
268
269 CFLAGS= -c -O2 -m486 -fomit-frame-pointer
270
271 o different first/second level table/switch combinations
272
273 0 - use a table
274 1 - use a simple switch
275 2 - use an expanded switch
276
277 i486DX4/100 - AMD
278
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
285
286 i486DX2/66
287
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
This page took 0.035116 seconds and 4 git commands to generate.