4 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
6 This directory contains the program PSIM that models the PowerPC
7 architecture. It can either be run stand alone (psim) or linked with
15 psim-sim-*.tar.gz simulator source code
17 psim-test-*.tar.gz test directory for simulator
19 psim-gdb-*.diff.gz patches to integrated psim
24 gnu-gdb-*.diff.gz patches to gdb that may have
25 already been merged into the
28 gnu-*-*.diff.gz Other noise
33 o Install flex, bison, gnu-make, native gcc and probably also byacc.
36 o First you will need a fairly current copy of GDB (try the ftp site
37 ftp.cygnus.com:pub). I've built it with a beta version of gdb-4.15.
41 $ gunzip < gdb-4.15.tar.gz | tar xf -
44 o Apply any patches that haven't yet been merged into the GDB source
48 $ gunzip < ../psim-gdb-*.diff.gz | patch -p1
49 $ gunzip < ../gnu-gdb-*.diff.gz | patch -p1
52 o Unpack the psim source code (and optionally the test directory)
55 $ gunzip < ../psim-sim-*.tar.gz | tar xvf -
56 $ gunzip < ../psim-test-*.tar.gz | tar xvf -
59 o Configure gdb as per normal. I use something along the lines of:
62 $ CC=gcc ./configure --target=powerpcle-unknown-eabi
65 o Build your entire gdb tree as per normal. Something along the
76 o Install it it all as per normal. Something along the lines of:
81 The program sim/ppc/psim is not installed.
86 PSIM can either be run as a stand alone program or as part
87 of gdb. The psim-test archive contains pre-compiled and
88 linked programs that can be run on PSIM. The notes below
89 assume that you have unpacked that tar archive.
91 To rebuild the archive you will need to obtain a working
92 version of an ELF compiler/linker for the PowerPC.
94 Example of running PSIM:
96 Print out the users environment:
98 $ sim/ppc/psim sim/ppc/test/envp
100 Print out the arguments:
102 $ sim/ppc/psim sim/ppc/test/argv a b c
106 $ sim/ppc/psim sim/ppc/test/interrupt
108 Check that sbrk works
110 $ sim/ppc/psim sim/ppc/test/break
112 Try for speed. The program count contains a loop
113 of two instructions which is looped <arg> times.
114 See later for how to make PSIM run 10-100 times
117 $ time sim/ppc/sim sim/ppc/test/count 5000000
118 $ expr 10 \* 1000 \* 1000 / <seconds>
121 Example of running GDB:
123 The most important thing to be aware of is the fact
124 that before the simulator is used, the user must attach
125 to it (target sim) and than load the executable (load count).
128 $ powerpc-unknown-eabi-gdb count
138 CONFIGURATION: Making it go faster
140 See the file sim/ppc/config.h (a.k.a. sim/ppc/data/ppc-config)
146 SMP, dual-endian, VEA and OEA models, hardware devices
147 (console, icu, reset) ...
152 Configuration could be better.
154 HTAB (page) code for OEA model untested. Some of the vm code
155 instructions unimplemented.
157 Doesn't detect/handle changing endian bits. In fact they are
160 Return from interrupt instruction unimplemented.
162 Flush instruction cache instructions do nothing. Perhaphs they
163 should (if there is an instruction cache) flush it.
165 PowerOpen VEA model (a.k.a XCOFF a.k.a AIX) broken. It was
166 working but that is before I changed the create stack frame
167 code into an ELF version.
169 OpenBoot and PR*P interfaces missing. Open boot could be
170 implemented by putting special instructions at the address
171 of the OpenBoot callback functions. Those instructions
172 could than emulate OpenBoot behavour.
174 VEA memory read/write performance could be improved by merging
177 When reading in a VEA executable, the binaries text and data
178 sections are not made page aligned.
180 Missing or commented out instructions.
182 Lack of floating point support.
183 [workaround: build everything using -msoft-float]
187 Event code for pending events from signal handlers not
190 Better and more devices.
192 Only two device trees VEA and OEA (clayton) and those hard coded.
193 Should be possible to specify a file containing a device tree
194 description as the program to run. At present it a device tree
195 file is detected causing psim to abort.
197 I wonder if I've got my ppc.instructions copyright
203 Thanks go to the following who each helped in some way.
205 Allen Briggs, Bett Koch, David Edelsohn,
206 Michael Meissner, Bob Mercier, Richard Perini,
207 Richard Stallman, Mitchele Walker
210 ----------------------------------------------------------------
213 Random notes on performance:
217 time ../psim count `expr 10000000 / 2`
218 time ../psim volatile-count `expr 10000000 / 7`
220 Where 2 and 7 are the number of instructions in the main loop.
227 CFLAGS= -c -O2 -m486 -fomit-frame-pointer
229 o different first/second level table/switch combinations
232 1 - use a simple switch
233 2 - use an expanded switch
237 1/108/140 - switch=0/0/0,expand=2,inline=2,nia=1,cache=1
238 1/114/140 - switch=0/0/0,expand=2,inline=2,nia=1,cache=1
239 1/137/149 - switch=0/0,expand=2,inline=1,nia=1,cache=1
240 1/144/155 - switch=2/1,expand=2,inline=1,nia=1,cache=1
241 1/153/159 - switch=2/1,expand=0,inline=1,nia=1,cache=1
242 1/185/189 - switch=0/0,expand=0,inline=1,nia=1
246 1/572/695 - switch=1/1,expand=0,inline=0
247 1/579/729 - switch=0/0,expand=0,inline=0
248 1/570/682 - switch=2/2,expand=0,inline=0
249 1/431/492 - switch=0/0,expand=0,inline=1,nia=0
250 1/271/292 - switch=2/1,expand=0,inline=1,nia=0
251 1/270/316 - switch=2/2,expand=0,inline=1,nia=0
252 1/271/281 - switch=1/1,expand=0,inline=1,nia=1
253 1/267/274 - switch=2/1,expand=0,inline=1,nia=1