INSTALL 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. PSIM - model the PowerPC environment
  2. Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>.
  3. ----------------------------------------------------------------------
  4. Building PSIM
  5. This file describes how to build the program PSIM
  6. o Walk through a basic build
  7. o Discussion of PSIM's components and
  8. how they relate to the build process
  9. o Detailed description of each of PSIM's
  10. compile time configuration options
  11. ----------------------------------------------------------------------
  12. BUILDING PSIM:
  13. PSIM 1.0.2 is included in GDB-4.16. To build PSIM you will need the
  14. following:
  15. gdb-4.16.tar.gz Available from your favorite GNU
  16. ftp site
  17. gcc GCC version two includes suport
  18. for long long (64bit integer)
  19. arrithemetic which PSIM uses. Hence
  20. it is recommended that you build PSIM
  21. using GCC.
  22. Method:
  23. 1. Unpack gdb
  24. $ cd .../scratch
  25. $ gunzip < gdb-4.16.tar.gz | tar xf -
  26. 2. Configure gdb
  27. First consult the gdb documentation
  28. $ cd .../scratch
  29. $ cd gdb-4.16
  30. $ more README
  31. $ more gdb/README
  32. then something like (I assume SH):
  33. $ CC=gcc ./configure \
  34. --enable-sim-powerpc \
  35. --target=powerpc-unknown-eabi \
  36. --prefix=/applications/psim
  37. 4. Build (again specifying GCC)
  38. $ make CC=gcc
  39. alternatively, if you are short on disk space or only
  40. want to build the simulator:
  41. $ ( cd libiberty && make CC=gcc )
  42. $ ( cd bfd && make CC=gcc )
  43. $ ( cd sim/ppc && make CC=gcc )
  44. 5. Install
  45. $ make CC=gcc install
  46. or just
  47. $ cp gdb/gdb ~/bin/powerpc-unknown-eabisim-gdb
  48. $ cp sim/ppc/run ~/bin/powerpc-unknown-eabisim-run
  49. ----------------------------------------------------------------------
  50. UPDATING PSIM:
  51. A PSIM is an ongoing development. Occasional snapshots which both contain new
  52. features and fix old bugs are made available. See the ftp directory:
  53. ftp://ftp.ci.com.au/pub/psim/beta
  54. or ftp://cambridge.cygnus.com/pub/psim/beta
  55. for the latest version. To build/install one of these snapshots, you
  56. replace the sim/ppc found in the gdb archive with with one from the
  57. snapshot. Then just re-configure and rebuild/install.
  58. Procedure:
  59. 0. A starting point
  60. $ cd gdb-4.16
  61. 1. Remove the old psim directory
  62. $ mv sim/ppc sim/old.ppc
  63. 2. Unpack the new one
  64. $ gunzip < ../psim-NNNNNN.tar.gz | tar tf -
  65. $ gunzip < ../psim-NNNNNN.tar.gz | tar tf -
  66. 3. Reconfigure/rebuild (as seen above):
  67. $ CC=gcc ./configure \
  68. --enable-sim-powerpc \
  69. --target=powerpc-unknown-eabi \
  70. --prefix=/applications/psim
  71. $ make CC=gcc
  72. ----------------------------------------------------------------------
  73. UPDATES TO GDB:
  74. From time to time, problems involving the integration of PSIM into gdb
  75. are found. While eventually each of these problems is resolved there
  76. can be periouds during which a local hack may be needed.
  77. At the time of writing the following were outstanding:
  78. ATTACH command:
  79. ftp://ftp.ci.com.au/pub/psim/gdb-4.15+attach.diff.gz
  80. or ftp://cambridge.cygnus.com/pub/psim/gdb-4.15+attach.diff.gz
  81. PSIM, unlike the other simulators found in GDB, is able to load
  82. the description of a target machine (including the initial
  83. state of all processor registers) from a file.
  84. Unfortunatly GDB does not yet have a standard command that
  85. facilitates the use of this feature. Until such a command is
  86. added, the patch (hack?) gdb-4.15+attach.diff.gz can be used to
  87. extend GDB's attach command so that it can be used to initialize
  88. the simulators configuration from a file.
  89. ----------------------------------------------------------------------
  90. RUNNING PROGRAMS:
  91. See the file:
  92. ftp://ftp.ci.com.au/pub/psim/RUN
  93. or ftp://cambridge.cygnus.com/pub/psim/RUN
  94. ----------------------------------------------------------------------
  95. COMPILE TIME CONFIGURATION OPTIONS:
  96. PSIM's compile time configuration is controlled by autoconf. PSIM's
  97. configure script recognises options of the form:
  98. --enable-sim-<option>[=<val>]
  99. And can be specified on the configure command line (at the top level
  100. of the gdb directory tree) vis:
  101. $ cd gdb-4.15
  102. $ CC=gcc ./configure \
  103. --target=powerpc-unknown-eabisim \
  104. --prefix=/applications/psim \
  105. --enable-sim-inline
  106. $ make CC=gcc
  107. For a brief list of PSIM's configuration options, configure --help
  108. will list them vis:
  109. $ cd sim/ppc
  110. $ ./configure --help
  111. Each PSIM specific option is discussed in detail below.
  112. --enable-sim-cflags=<opts>
  113. Specify additional C compiler flags that are to be used when compiling
  114. just PSIM.
  115. PSIM places heavy demands on both the host machine and its C compiler. So that
  116. the builder has better control over the compiler the above option can be used
  117. to pass additional options to the compiler while PSIM is being built.
  118. Ex: No debug information
  119. PSIM can be built with everything inline. Unfortunately, because of
  120. all the debugging information generated the C compiler can grow very
  121. very large as a result. For GCC, the debug information can be
  122. restricted with the `-g0' option. To specify that this option should
  123. be include in the CFLAGS when compiling the psim source code use:
  124. --enable-sim-cflags=-g0
  125. Ex: Additional optimization flags
  126. A significant gain in performance can be achieved by tuning the
  127. optimization flags passed to the C compiler. For instance on an x86
  128. you may consider:
  129. --enable-sim-cflags='-g0 -O2 -fno-strength-reduce -f...'
  130. --enable-sim-warnings=<flags>
  131. Turn on additional GCC specific checks.
  132. Some hosts (NetBSD, Linux, Solaris-2.5) have complete header files
  133. that include correct prototypes for all library functions. On such
  134. hosts, PSIM can be built with many more than the standard C checks
  135. enabled. The option --enable-sim-warnings controls this.
  136. Ex: Default warnings
  137. With just --enable-sim-warnings, the following -W options are enabled:
  138. -Werror -Wall -Wpointer-arith -Wmissing-prototypes.
  139. --enable-sim-opcode=which
  140. Specify the file containing the rules for generating the instruction
  141. decode and execute functions from the file ppc-instructions.
  142. The form of the instruction decode and execute functions is controlled
  143. by an opcode table. It specifies: the combination of switch
  144. statements and jump tables to use when decoding an instruction and how
  145. much of each instruction should be decoded before calling the
  146. instruction execute function.
  147. PSIM includes a number of opcode tables:
  148. psim-opcode-simple
  149. Generates a small compact two level switch statement
  150. that will compile quickly and run reasonably fast.
  151. This may be useful on a small machine.
  152. psim-opcode-complex
  153. (the default) A fairly aggressive instruction decode
  154. table that includes the breaking out of a number
  155. of special instruction cases (eg RA==0 vs RA!=0).
  156. psim-opcode-flat
  157. Identical to complex except a switch statement
  158. is used. Ideal for when the icache is being
  159. disabled.
  160. psim-opcode-stupid
  161. In addition to the instruction decodes performed
  162. by psim-opcode-complex, this also full decodes mtspr,
  163. mfspr, and branch instructions. The table generated
  164. is very large and, as a consequence, only performs
  165. well on machines with large caches.
  166. ppc-opcode-test-1
  167. ppc-opcode-test-2
  168. Generate test (but workable) tables. These exercise
  169. PSIM's ability to generate instruction decode functions
  170. that are a combination of jump-tables and switch statements.
  171. The program igen generates the instruction tables from the opcode
  172. table and the ppc-instruction table.
  173. --enable-sim-switch
  174. Enable/disable the use of a switch statement when looking up the
  175. attributes of a SPR register.
  176. The PowerPC architecture defines a number of Special Purpose Registers
  177. (SPR's). Associated with each of these registers are a number of
  178. attributes (such as validity or size) which the instructions
  179. mtspr/mfspr query as part of their execution.
  180. For PSIM, this information is kept in a table (ppc-spr-table). The
  181. program dgen converts this table into lookup routines (contained in
  182. the generated files spreg.h spreg.c) that can be used to query an
  183. SPR's attributes. Those lookup routines are either implemented as
  184. a table or alternatively as a number of switch statements:
  185. spr_table spr_info[] = { .... };
  186. int spr_length(sprs spr) { return spr_info[spr].length; }
  187. vs
  188. int spr_length(sprs spr) { switch (spr) { case ..: return ..; } }
  189. In general the first implementation (a table) is the most efficient.
  190. It may, however, prove that when performing an aggressive optimization
  191. where both the SPR is known and the above function is being inlined
  192. (with the consequence that GCC can eliminate the switch statement)
  193. that the second choice is improves performance.
  194. In practice, only a marginal (if any benefit) has ever been seen.
  195. --enable-sim-duplicate
  196. Create a duplicate copy of each instruction function hardwiring
  197. instruction fields that would have otherwise have been variable.
  198. As discussed above, igen outputs a C function generated from the file
  199. ppc-instructions (using the opcode rules) for each of the
  200. instructions. Thus multiple entries in the instruction decode tables
  201. may be pointing back at the same function. Enabling duplicate, will
  202. result in psim creating a duplicate of the instruction's function for
  203. each different entry in the instruction decode tables.
  204. For instance, given the branch instruction:
  205. 0.19,6.BO,11.BI,16./,21.528,31.LK
  206. ...
  207. if (LK) LR = (spreg)IEA(CIA + 4);
  208. ...
  209. igen as part of its instruction lookup table may have generated two
  210. different entries - one for LK=0 and one for LK=1. With duplicate
  211. enabled, igen outputs (almost) duplicate copies of branch function,
  212. one with LK hardwired to 0 and one with LK hardwired to 1.
  213. By doing this the compiler is provided with additional information that
  214. will allow it possibly eliminate dead code. (such as the assignment
  215. to LK if LR==0).
  216. Ex: default
  217. Because this feature is such a big win, --enable-sim-duplicate is
  218. turned on by default.
  219. Ex: A small machine
  220. Only rarely (eg on a very small host) would this feature need to be
  221. disabled (using: --disable-sim-duplicate).
  222. --enable-sim-filter=rule
  223. Include/exclude PowerPC instructions that are specific to a particular
  224. implementation.
  225. Some of the PowerPC instructions included in the file ppc-instructions
  226. are limited to certain specific PPC implementations. For instance,
  227. the instruction:
  228. 0.58,6.RT,11.RA,16.DS,30.2:DS:64::Load Word Algebraic
  229. Is only valid for the 64bit architecture. The enable-sim-filter flag
  230. is passed to igen so that it can `filter out' any invalid
  231. instructions. The filter rule has the form:
  232. -f <name>
  233. thus:
  234. --enable-sim-filter='-f 64'
  235. (the default) would filter out all 64bit instructions.
  236. Ex: Remove floating point instructions
  237. A given 32bit PowerPC implementation may not include floating point
  238. hardware. Consequently there is little point in including floating
  239. point instructions in the instruction table. The option:
  240. --enable-sim-filter='-f 64 -f f'
  241. will eliminate all floating point instructions from the instruction
  242. table.
  243. --enable-sim-icache=size
  244. Set the size of the cache used to hold decoded instructions.
  245. Psim executes instructions in two separate steps:
  246. o instruction fetch/decode
  247. o instruction execution
  248. For a given instruction, the first stage need only be executed once
  249. (the first time the instruction is encountered) while the second stage
  250. must be executed every time the program `executes' that instruction.
  251. Exploiting this, PSIM can maintain a cache of decoded instructions.
  252. It will then use the decoded instruction from the cache in preference
  253. to fetching/decoding the real instruction from memory.
  254. Ex: default
  255. Because this feature is normally such a big win, it is enabled by
  256. default (with the cache size set to 1024 entries).
  257. The 1024 entries equals 4096 bytes (or one page) of instructions.
  258. Larger caches can be used but with caution - PSIM does not check for
  259. address aliasing within its instruction cache.
  260. Ex: disable the cache
  261. There may be cases (for instance where the cache has a low hit rate)
  262. where the psim performs better with no instruction cache. For such
  263. situations, the cache can be disabled vis: --disable-sim-icache.
  264. --enable-sim-inline[=module]
  265. Specify the inlining of one or more modules.
  266. Many architectures (in particular the x86) suffer from a large
  267. function call overhead. By eliminating function calls (through
  268. inlining of functions) a large performance gain can be achieved.
  269. In PSIM, modules are inlined in one of two possible ways. Some
  270. modules (such as the byte swapping code) can be inlined into any
  271. module that calls them. Other modules, due to complex
  272. interdependencies, are only inlined as a group when compiling the
  273. external interface module psim.c.
  274. Ex: default
  275. By default the modules endian (handle be/le), bits (manipulate
  276. bit-fields within words), cpu (the processor object) and events
  277. (timers) are inlined in any module that calls them. This gives a
  278. reasonable performance gain with little additional compilation
  279. overhead.
  280. Ex: recommended --enable-sim-inline
  281. Assuming you machine is reasonably well configured, this option is
  282. highly recommended. On the x86 several orders of magnitude
  283. improvement in performance is possible.
  284. Ex: fine tuning
  285. The file std-config.h contains a detailed description of how the
  286. inlining works. Individual modules can be inlined by specifying them.
  287. For if you have a very large cache the model module could be inlined
  288. with:
  289. --enable-sim-inline=MODEL
  290. --enable-sim-bswap
  291. (x86 specific) Use the i486/P5/P6 byte swap instruction.
  292. PSIM contains generic byte swapping code. For the x86 (P[4-6]) PSIM
  293. can be built so that it uses the bswap instruction instead of relying
  294. on the compiler to generate byte swap code.
  295. Ex: default
  296. By default, when compiling with GCC-2 on an i486/P5/P6 the bswap
  297. instruction is used.
  298. --enable-sim-endian=endian
  299. Specify the byte order of the target.
  300. By default, PSIM is able to execute both big and little endian
  301. executables. As a consequence, every byte swap routine includes a
  302. test to see if the byte swap is really needed. By specifying the byte
  303. order of the target (and the host below) the need for this test can be
  304. eliminated.
  305. Clearly setting the byte order of the target is only useful when known
  306. before hand.
  307. --enable-sim-hostendain=end
  308. As above but for the host.
  309. Normally this option should not be needed. configure (autoconf) should
  310. determine the byte order of the host automatically. However if for
  311. some reason there is a problem, this option can be used to override
  312. autoconf.
  313. --enable-sim-smp=n
  314. Set the maximum number of processors that PSIM can model.
  315. Psim can model (with small limitation discussed else where) a
  316. multi-processor PowerPC environment. While the overhead of
  317. co-ordinating the execution of a number of processors is relatively
  318. small it is still significant when compared to handling only one
  319. processor.
  320. This option only sets the maximum number of processors that can be
  321. simulated. The number active during a given simulation run us
  322. determined at run time.
  323. Ex: default
  324. By default 5 processors are configured but only one is enabled.
  325. Additional processors can be enabled with the runtime option:
  326. -o '/openprom/options/smp 5'
  327. Ex: recommended
  328. Unless you intend studying multi-processor systems there is little reason for
  329. having PSIM configured with SMP support. Specifying:
  330. --disable-sim-smp
  331. or --enable-sim-smp=0
  332. will eliminate any SMP such as:
  333. for (cpu = 0; cpu < nr_cpus; cpu++)
  334. ...
  335. --enable-sim-xor-endian=n
  336. Set the byte-size of the bus involved in the PowerPC's xor endian byte
  337. swapping.
  338. The PowerPC's implementation of BE/LE mode is different to what a
  339. programmer may first expect. The details of this implementation are
  340. discussed at length in PowerPC documentation.
  341. Ex: default
  342. By default this is configured with a value of 8 (the bus size of most
  343. 60x processors).
  344. Ex: recommended
  345. Unless you are expecting to test/debug PowerPC be/le switching code
  346. this option is of little use and should be disabled:
  347. --disable-sim-xor-endian
  348. --enable-sim-bitsize=n
  349. Specify the bit size (32/64) of the PowerPC to be modelled.
  350. Note: By default 32 is specified. The implementation of the 64bit
  351. architecture is still under development.
  352. --enable-sim-hostbitsize=32|64
  353. As above but for the host.
  354. NOTE: Psim has yet to be built on a 64bit host.
  355. --enable-sim-env=env
  356. Hardwire the PowerPC environment being modelled (user, virtual or
  357. operating).
  358. The PowerPC architecture defines three different levels of compliance to its
  359. architectural specification. These environments are discussed in detail in
  360. PowerPC publications.
  361. user - normal user programs
  362. virtual - an extension of the user environment (includes timers)
  363. operating - kernel code
  364. Ex: default
  365. By default all three environments are supported.
  366. Ex: recommended
  367. If you only intend running psim with user (or operating) code then
  368. PSIM should be configured accordingly. For user code, it eliminates:
  369. support for timers and events and redundant VM calls.
  370. --enable-sim-timebase
  371. Enable/disable the time base register.
  372. The PowerPC architecture (virtual environment) includes a time base
  373. register. Maintaining that register incurs an overhead in
  374. performance that can be eliminated by eliminating time-base register
  375. support.
  376. Ex: default
  377. Normally this option is not used. Instead --enable-sim-env (above) us
  378. used to disable/enable features such as the timebase register.
  379. --enable-sim-alignment=align
  380. Control the PowerPC's memory access alignment restrictions.
  381. The PowerPC in LE mode only allows memory transfers of a correctly
  382. aligned size/address. The above option controls how misaligned
  383. accesses are handled.
  384. strict All accesses must be correctly aligned
  385. nonstrict Unaligned access allowed (the are split
  386. into a number of aligned accesses).
  387. Ex: default
  388. Unless otherwise specified PSIM will auto configure a BE program to
  389. allow miss-aligned accesses while a LE program will not.
  390. Ex: 604e
  391. The recently announced 604e processor allows miss-aligned accesses in both
  392. BE and LE modes. If modeling the 604e then you should specify:
  393. --enable-sim-alignment=nonstrict
  394. --enable-sim-trace
  395. Include code to trace PSIM's internal progress (also controlled by the
  396. -t option).
  397. Checking to see if a trace message should be output slows down a
  398. simulation. Disabling this option (--disable-sim-trace) eliminates
  399. completely that code.
  400. --enable-sim-assert
  401. Include the code that checks the correctness of parts of PSIM.
  402. Eliminating such code (--disable-sim-assert) eliminates internal
  403. consistency tests and their overhead.
  404. --enable-sim-reserved-bits
  405. Include code to check that the reserved fields of the instruction are
  406. zero.
  407. The PowerPC architecture defines certain fields of some instructions
  408. as reserved (`/'). By default, for each instruction, PSIM will check
  409. the reserved fields causing an invalid instruction exception if a
  410. field is invalid. Disabling this option eliminates this test. This
  411. is at the slight risk of PSIM treating an invalid instruction as
  412. valid.
  413. --enable-sim-float
  414. Include support for hardware floating point.
  415. --enable-sim-monitor=mon
  416. Include support for basic instruction counting.
  417. If you are not interested in the performance of either you program or
  418. the simulator then you can disable this option.
  419. --enable-sim-model=which
  420. Hardwire the processor that will be used as a reference when modeling
  421. execution units.
  422. --enable-sim-default-model=which
  423. Specify the processor of choice for the execution unit model.
  424. --enable-sim-model-issue
  425. Include support for the modeling of processor execution units.
  426. ----------------------------------------------------------------------
  427. TYPICAL CONFIGURATION OPTIONS:
  428. VEA CODE ONLY:
  429. Here of note are:
  430. o ramp up the compiler options (some
  431. of the below are P5 specific).
  432. o disable anything not used
  433. CC=gcc ./configure \
  434. --prefix=/applications/psim \
  435. --target=powerpc-unknown-eabi \
  436. --enable-sim-powerpc \
  437. --enable-sim-warnings \
  438. --enable-sim-inline \
  439. --disable-sim-smp \
  440. --enable-sim-duplicate \
  441. --enable-sim-endian=big \
  442. --disable-sim-xor-endian \
  443. --enable-sim-env=user \
  444. --disable-sim-reserved-bits \
  445. --disable-sim-assert \
  446. --disable-sim-trace \
  447. --enable-sim-cflags='-g0,-O2,-fno-strength-reduce,-fomit-frame-pointer'
  448. OEA CODE ONLY:
  449. The key configuration changes are:
  450. o turn off the instruction cache. The overhead
  451. of flushing and reloading it is greater than
  452. not having a cache.
  453. o use a switch statement (ppc-opcode-flat) for
  454. the instruction decode and then (-O3) fully
  455. inline all functions.
  456. o --enable-sim-warnings is not present. GCC (2.7.2)
  457. gets confused by the instruction decode table
  458. generated by igen (contains a perfect switch)
  459. and, as a consequence, generates a bogus warning.
  460. CC=gcc ./configure \
  461. --prefix=/applications/psim \
  462. --target=powerpc-unknown-eabi \
  463. --enable-sim-powerpc \
  464. --enable-sim-inline \
  465. --disable-sim-smp \
  466. --enable-sim-duplicate \
  467. --enable-sim-endian=big \
  468. --disable-sim-xor-endian \
  469. --enable-sim-env=operating \
  470. --disable-sim-reserved-bits \
  471. --disable-sim-assert \
  472. --disable-sim-trace \
  473. --enable-sim-opcode=ppc-opcode-flat \
  474. --disable-sim-icache \
  475. --enable-sim-cflags='-g0,-O3,-fno-strength-reduce,-fomit-frame-pointer'