RUN 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. PSIM - model the PowerPC environment
  2. Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>.
  3. ----------------------------------------------------------------------
  4. Running PSIM
  5. This file describes how to run the program PSIM.
  6. o Walk through a number of examples from the
  7. pre-built tar archive psim-test.
  8. o Looks at the device tree used by PSIM.
  9. o Notes on building a programmer environment to
  10. use with PSIM (BSD/UEA and BUG/OEA)
  11. ----------------------------------------------------------------------
  12. RUNNING PSIM:
  13. The compressed tar archive psim-test available from:
  14. ftp://ftp.ci.com.au/pub/psim/psim-test-1.0.1.tar.gz
  15. or ftp://cambridge.cygnus.com/pub/psim/psim-test-1.0.1.tar.gz
  16. contains a number of pre-built programs for running under PSIM. Each
  17. pre-built binary is built both big and little endian. The suffixes
  18. .be/.le (executables) .bo/.lo (object files) and .ba/.la (libraries)
  19. are used.
  20. To run one of these programs, use:
  21. powerpc-unknown-eabi-run <image>
  22. for instance:
  23. powerpc-unknown-eabi-run psim-test/uea/envp
  24. The program envp prints out your shells environment - very useful!
  25. More generally psim is run as (this is part of the output from the -h
  26. option):
  27. psim [ <psim-option> ... ] <image> [ <image-arg> ... ]
  28. Where
  29. <image> Name of the PowerPC program to run.
  30. This can either be a PowerPC binary or
  31. a text file containing a device tree
  32. specification.
  33. PSIM will attempt to determine from the
  34. specified <image> the intended emulation
  35. environment.
  36. If PSIM gets it wrong, the emulation
  37. environment can be specified using the
  38. `-e' option (described below).
  39. <image-arg> Argument to be passed to <image>
  40. These arguments will be passed to
  41. <image> (as standard C argv, argc)
  42. when <image> is started.
  43. <psim-option> See below
  44. The following are valid <psim-option>s:
  45. -m <model> Specify the processor to model (604)
  46. Selects the processor to use when
  47. modeling execution units. Includes:
  48. 604, 603 and 603e
  49. -e <os-emul> specify an OS or platform to model
  50. Can be any of the following:
  51. bug - OEA + MOTO BUG ROM calls
  52. netbsd - UEA + NetBSD system calls
  53. chirp - OEA + a few OpenBoot calls
  54. -i Print instruction counting statistics
  55. -I Print execution unit statistics
  56. -r <size> Set RAM size in bytes (OEA environments)
  57. -t [!]<trace> Enable (disable) <trace> option
  58. -o <spec> add device <spec> to the device tree
  59. -h -? -H give more detailed usage
  60. The `-H' option gives a long usage output. This includes a complete
  61. list of all the pre-configured devices.
  62. ----------------------------------------------------------------------
  63. RUNNING GDB:
  64. If you built PSIM with gdb then the following is a quick start
  65. tutorial.
  66. At present GDB, if configured big-endian (say) unlike PSIM, does not
  67. support the debugging of little endian binaries. If you find that
  68. your program won't run at all, make certain that GDB and your
  69. program's endianness match.
  70. The most important thing is that before you can run the simulator you
  71. must enable it. For the simulator, gdb is started like any program:
  72. $ powerpc-unknown-eabi-gdb psim-test/uea/envp.be
  73. Next the simulator is enabled. The command `target sim' accepts the
  74. same options as can be specified on the PSIM command line.
  75. (gdb) target sim
  76. To trace the communication between psim and gdb specify `target sim -t
  77. gdb'. Once enabled, the binary needs to be loaded, any breakpoints of
  78. interest set, and the program run:
  79. (gdb) load
  80. (gdb) break main
  81. (gdb) run
  82. .
  83. .
  84. .
  85. In addition, if you are wanting to run a program described by a device
  86. tree you can `attach' to the simulation using (I assume that you have
  87. applied the attach patch):
  88. $ cd psim-test/tree
  89. $ powerpc-unknown-eabi-gdb
  90. (gdb) target sim
  91. (gdb) attach device-tree
  92. (gdb) run
  93. Here GDB takes the programs initial state from the attached
  94. device-tree instead of forcing initialisation.
  95. ----------------------------------------------------------------------
  96. PROFILING:
  97. PSIM includes a number of performance monitoring (profiling)
  98. facilities:
  99. o instruction frequency counting
  100. o execution unit modeling (records
  101. effective usage of units).
  102. o instruction cache performance
  103. As discussed in the file INSTALL, each can be configured to individual
  104. requirements.
  105. -i Enable instruction counting.
  106. The frequency of all instructions is tabulated. In
  107. addition (f configured) the hit/miss rate of the
  108. instruction cache is output.
  109. -I Enable execution unit analysis.
  110. In addition to counting basic instructions also model
  111. the performance of the processors execution units
  112. -m <processor>
  113. Select the processor to be modelled.
  114. For execution unit analysis specify the processor that
  115. is to be analysed. By default the 604 is modelled
  116. however, support for other processors such as the
  117. 603 and 603e is included.
  118. The output from a performance run (on a P90) for the program
  119. psim-test/profile/bench is below. In this run psim was fairly
  120. agressively configured (see the file INSTALL for compile time
  121. configuration).
  122. CPU #1 executed 41,994 AND instructions.
  123. CPU #1 executed 519,785 AND Immediate instructions.
  124. CPU #1 executed 680,058 Add instructions.
  125. CPU #1 executed 41,994 Add Extended instructions.
  126. CPU #1 executed 921,916 Add Immediate instructions.
  127. CPU #1 executed 221,199 Add Immediate Carrying instructions.
  128. CPU #1 executed 943,823 Add Immediate Shifted instructions.
  129. CPU #1 executed 471,909 Add to Zero Extended instructions.
  130. CPU #1 executed 571,915 Branch instructions.
  131. CPU #1 executed 1,992,403 Branch Conditional instructions.
  132. CPU #1 executed 571,910 Branch Conditional to Link Register instructions.
  133. CPU #1 executed 320,431 Compare instructions.
  134. CPU #1 executed 471,911 Compare Immediate instructions.
  135. CPU #1 executed 145,867 Compare Logical instructions.
  136. CPU #1 executed 442,414 Compare Logical Immediate instructions.
  137. CPU #1 executed 1 Condition Register XOR instruction.
  138. CPU #1 executed 103,873 Divide Word instructions.
  139. CPU #1 executed 104,275 Divide Word Unsigned instructions.
  140. CPU #1 executed 132,510 Extend Sign Byte instructions.
  141. CPU #1 executed 178,895 Extend Sign Half Word instructions.
  142. CPU #1 executed 871,920 Load Word and Zero instructions.
  143. CPU #1 executed 41,994 Move From Condition Register instructions.
  144. CPU #1 executed 100,005 Move from Special Purpose Register instructions.
  145. CPU #1 executed 100,002 Move to Special Purpose Register instructions.
  146. CPU #1 executed 804,619 Multiply Low Word instructions.
  147. CPU #1 executed 421,201 OR instructions.
  148. CPU #1 executed 471,910 OR Immediate instructions.
  149. CPU #1 executed 1,292,020 Rotate Left Word Immediate then AND with Mask instructions.
  150. CPU #1 executed 663,613 Shift Left Word instructions.
  151. CPU #1 executed 1,151,564 Shift Right Algebraic Word Immediate instructions.
  152. CPU #1 executed 871,922 Store Word instructions.
  153. CPU #1 executed 100,004 Store Word with Update instructions.
  154. CPU #1 executed 887,804 Subtract From instructions.
  155. CPU #1 executed 83,988 Subtract From Immediate Carrying instructions.
  156. CPU #1 executed 1 System Call instruction.
  157. CPU #1 executed 207,746 XOR instructions.
  158. CPU #1 executed 23,740,856 cycles.
  159. CPU #1 executed 10,242,780 stalls waiting for data.
  160. CPU #1 executed 1 stall waiting for a function unit.
  161. CPU #1 executed 1 stall waiting for serialization.
  162. CPU #1 executed 1,757,900 times a write-back slot was unavailable.
  163. CPU #1 executed 1,088,135 branches.
  164. CPU #1 executed 2,048,093 conditional branches fell through.
  165. CPU #1 executed 1,088,135 successful branch predictions.
  166. CPU #1 executed 904,268 unsuccessful branch predictions.
  167. CPU #1 executed 742,557 branch if the condition is FALSE conditional branches.
  168. CPU #1 executed 1,249,846 branch if the condition is TRUE conditional branches.
  169. CPU #1 executed 571,910 branch always conditional branches.
  170. CPU #1 executed 9,493,653 1st single cycle integer functional unit instructions.
  171. CPU #1 executed 1,220,900 2nd single cycle integer functional unit instructions.
  172. CPU #1 executed 1,254,768 multiple cycle integer functional unit instructions.
  173. CPU #1 executed 1,843,846 load/store functional unit instructions.
  174. CPU #1 executed 3,136,229 branch functional unit instructions.
  175. CPU #1 executed 16,949,396 instructions that were accounted for in timing info.
  176. CPU #1 executed 871,920 data reads.
  177. CPU #1 executed 971,926 data writes.
  178. CPU #1 executed 221 icache misses.
  179. CPU #1 executed 16,949,396 instructions in total.
  180. Simulator speed was 250,731 instructions/second
  181. ----------------------------------------------------------------------
  182. PSIM CONFIGURATION - THE DEVICE TREE
  183. Internally PSIM's configuration is controlled by a tree data
  184. structure. This structure, created at run-time, intentionally
  185. resembles the device tree used by OpenBoot firmware to describe a
  186. machines hardware configuration.
  187. PSIM can either create its device tree using a builtin emulation or
  188. from one read in from a file.
  189. During startup, the device tree is created using the following steps:
  190. o Initial empty tree is created
  191. o Any tree entry options specified on the
  192. command line are merged in (the -o <entry>
  193. option is used).
  194. It should be pointed out that most of the
  195. command line options (eg -r, -e, -m, -t
  196. are all just short hand for corresponding
  197. -o options).
  198. o If the specified program is a device tree spec, that
  199. is loaded.
  200. If the specified program is a text file it is assumed
  201. that that file contains a further specification of the
  202. simulators device tree. That tree is loaded and
  203. merged with the current tree options.
  204. o The selected emulation fills out any remaining details.
  205. By this stage the emulation environment that the program
  206. needs will either be specified in the device tree
  207. (through the -e option) or determined from the
  208. characteristics of the binary.
  209. The selected emulation will then fill out any missing
  210. nodes in the device tree.
  211. Most importantly earlier additions to the tree are not overridden by
  212. later additions. Thus, command line options override information
  213. found in the program file and both override any builtin emulation
  214. entries.
  215. The following is a summary of the most useful runtime configuration
  216. options:
  217. -e <os-emul>
  218. -o '/openprom/options/os-emul <os-emul>'
  219. Run program using the <emulation> run-time
  220. environment.
  221. -r <ram-size>
  222. -o '/openprom/options/oea-memory-size <ram-size>'
  223. Set the size of the first bank of memory
  224. (RAM from address 0 up).
  225. -t print-device-tree
  226. -o '/openprom/trace/print-device-tree 1'
  227. -t dump-device-tree
  228. -o '/openprom/trace/dump-device-tree 1'
  229. Print out the device tree once it has been fully
  230. populated. For dump-device-tree, exit simulator after
  231. dumping the tree.
  232. PSIM is able to reload the dumped device tree.
  233. The format of the dumped tree is under development.
  234. -o '/openprom/options/smp <N>'
  235. Enable <N> processors for the simulation run.
  236. See the directory psim-test/oea for an example.
  237. -o '/openprom/options/alignment <N>'
  238. Where <N> is 1 - nonstrict or 2 - strict.
  239. Specify if the missaligned access are allowed
  240. (non-strict) or result in an alignment exception
  241. (strict).
  242. Devices (if included in the file device_table.c) can also be specified
  243. in a similar way. For instance, to add a second serial port, a
  244. command like:
  245. -o '/iobus@0x400000/console@0x000010'
  246. would create a `console' device at offset 0x10 within the `iobus' at
  247. memory address 0x400000.
  248. For more detailed information on device specifiers see the notes on
  249. the function dump_device_tree in the file device.c (found in the
  250. source code).
  251. ----------------------------------------------------------------------
  252. BUILDING A BUG/OEA DEVELOPMENT ENVIRONMENT
  253. Background:
  254. Included in many PowerPC systems is Motorola's BUG monitor. This
  255. monitor includes, for client programs, a set of services that allow
  256. that program to interact with hardware devices such as the console using
  257. a simple system call interface.
  258. PSIM is able to emulate a number of the services (including the
  259. console IO calls). If additional services are needed they can easily
  260. be added.
  261. Cygnus support's newlib library includes includes an interface to the
  262. MOTO BUG services. The notes below discuss how I both built and run
  263. programs compiled using this library on PSIM.
  264. The only confusing part about building a development environment based
  265. around newlib/binutils/gcc is a chicken/egg problem with include
  266. files:
  267. For GCC to build, a fairly complete set of include
  268. files must be installed but newlib won't install its
  269. include files until it has been built with gcc ...
  270. I get around this by installing the problematic include files by hand.
  271. Preparation:
  272. The following files are needed:
  273. From your favorite FTP site, the sources to gas/ld and gcc - mine
  274. happens to be archie.au :
  275. ftp://archie.au/gnu/binutils-2.6.tar.gz
  276. ftp://archie.au/gnu/gcc-2.7.2.tar.gz
  277. From ftp://ftp.cygnus.com/pub/newlib the source code to a library:
  278. ftp://ftp.cygnus.com/pub/newlib/newlib-1.7.0.tar.gz
  279. From ftp://ftp.ci.com.au/pub/psim some minor patches and updates to
  280. the above library:
  281. ftp://ftp.ci.com.au/pub/psim/newlib-1.7.0+float+ppc-asm.tar.gz
  282. ftp://ftp.ci.com.au/pub/psim/newlib-1.7.0+ppc-fix.diff.gz
  283. ftp://ftp.ci.com.au/pub/psim/binutils-2.6+note.diff.gz
  284. In addition you'll need to decide where you will be installing the
  285. development environment. You will notice that in the below I install
  286. things well away /usr/local instead installing everything under its
  287. own directory in /applications.
  288. Method:
  289. These notes are based on an installation performed on a Sun-OS-4/SPARC
  290. host. For other hosts and other configurations, the below should be
  291. considered as a guideline only.
  292. o Sanity check
  293. $ cd .../scratch # your scratch directory
  294. $ ls -1
  295. binutils-2.6.tar.gz
  296. binutils-2.6+note.diff.gz
  297. gcc-2.7.2,tar.gz
  298. newlib-1.7.0+float+ppc-asm.tar.gz
  299. newlib-1.7.0+ppc-fix.diff.gz
  300. newlib-1.7.0.tar.gz
  301. o Unpack/build/install binutils
  302. This is done first so that there is a gas/ld ready
  303. for the building of GCC and NEWLIB.
  304. $ cd .../scratch
  305. $ gunzip < binutils-2.6.tar.gz | tar xf -
  306. $ cd binutils-2.6
  307. Optionally apply the note patch
  308. $ gunzip ../binutils-2.6+note.diff.gz | patch
  309. Then continue with the build
  310. $ ./configure --target=powerpc-unknown-eabi \
  311. --prefix=/applications/psim
  312. $ make
  313. $ make install
  314. $ cd ..
  315. $ rm -rf binutils-2.6
  316. This also creates much of the installation directory
  317. tree.
  318. o Unpack newlib, install the include files so that they
  319. are ready for GCC's build.
  320. $ cd .../scratch
  321. $ gunzip < newlib-1.7.0.tar.gz | tar xf -
  322. New lib-1.7.0 had a few minor bugs (fixed in current):
  323. the header files float.h and ppc-asm.h were missing;
  324. the configure and Makefile's for the rs6000 (ppc) directory
  325. contained typos:
  326. $ cd .../scratch
  327. $ cd newlib-1.7.0
  328. $ gunzip < ../newlib-1.7.0+float+ppc-asm.tar.gz | tar xvf -
  329. $ gunzip < ../newlib-1.7.0+ppc-fix.diff.gz | patch -p1
  330. Finally copy the include files to where GCC will see them:
  331. $ cd .../scratch
  332. $ cd newlib-1.7.0/newlib/libc
  333. $ tar cf - include | \
  334. ( cd /applications/psim/powerpc-unknown-eabi && tar xf - )
  335. o Unpack/build gcc
  336. $ cd .../scratch
  337. $ gunzip < gcc-2.7.2,tar.gz | tar xf -
  338. $ cd gcc-2.7.2
  339. $ ./configure --target=powerpc-unknown-eabi \
  340. --prefix=/applications/psim
  341. $ make
  342. $ make install
  343. $ cd ..
  344. $ rm -rf gcc-2.7.2
  345. Gcc likes to install its own dummy version of float that
  346. just returns an error.
  347. $ more /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h
  348. $ rm /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h
  349. o Finish building/installing newlib
  350. $ cd .../scratch
  351. $ cd newlib-1.7.0
  352. $ ./configure --target=powerpc-unknown-eabi \
  353. --prefix=/applications/psim
  354. Your path will need to include the recently installed
  355. gas/gcc when building. Either add it to your path or
  356. use:
  357. $ PATH=/applications/psim/bin:$PATH make
  358. $ PATH=/applications/psim/bin:$PATH make install
  359. o Finally, test out the build
  360. $ cat hello.c
  361. main()
  362. {
  363. printf("hello world\n");
  364. }
  365. The binary is linked with an entry point less than 0x100000
  366. (1mb) so that psim will recognize the binary as needing
  367. the BUG/OEA instead of the BSD/UEA runtime environment.
  368. $ powerpc-unknown-eabi-gcc -v -o hello \
  369. -Wl,-Ttext,0x4000,-Tdata,0x10000 \
  370. /applications/psim/powerpc-unknown-eabi/lib/mvme-crt0.o \
  371. hello.c \
  372. -lc -lmvme
  373. $ powerpc-unknown-eabi-objdump -h hello
  374. $ powerpc-unknown-eabi-run hello
  375. It is also possible to force psim to use a specific
  376. run-time environment using the -e option vis:
  377. $ powerpc-unknown-eabi-run -e bug hello
  378. ----------------------------------------------------------------------
  379. BUILDING A BSD/UEA DEVELOPMENT ENVIRONMENT
  380. Background:
  381. For a UEA to be useful it needs a supporting run-time environment.
  382. PSIM implements a runtime environment based on the NetBSD system call
  383. interface.
  384. More than any thing, this user level emulation was the first
  385. implemented because I happened to have the NetBSD source code lying
  386. around.
  387. Preparation:
  388. This requires the NetBSD-1.1 source tree online. It can either be
  389. obtained vi ftp:
  390. try http://www.netbsd.org or ftp://ftp.netbsd.org
  391. Alternatively obtain one of the NetBSD cdrom's. Patches to this source
  392. tree that fill out much of the PowerPC code are available in:
  393. ftp://ftp.ci.com.au/pub/clayton
  394. Fetch everything in that directory - diffs, tar archives and scripts.
  395. In addition patches to the bintuils and gcc are in:
  396. ftp://ftp.ci.com.au/pub/psim/binutils-2.6+note.diff.gz
  397. ftp://ftp.ci.com.au/pub/psim/gcc-2.7.2+sys-types.diff.gz
  398. while the compiler (gcc) and assember (binutils) can be found at your
  399. favorite gnu ftp site. I used versions:
  400. gcc-2.7.2.tar.gz
  401. binutils-2.6.tar.gz
  402. Method:
  403. These notes are based on an installation performed on a Solaris2/x86
  404. host. For other hosts and other configurations, the below should be
  405. considered as a guideline only.
  406. o Sanity check
  407. I assume that you have already obtained the NetBSD-1.1 source
  408. code and unpacked it into the directory bsd-src. While the
  409. full NetBSD source tree may not be needed, things are easier
  410. if it is all online.
  411. $ cd .../scratch
  412. $ ls -1
  413. binutils-2.6.tar.gz
  414. binutils-2.6+note.diff.gz
  415. clayton-include-960203.diff.gz
  416. clayton-lib-960203.diff.gz
  417. clayton-lib-960203.tar.gz
  418. clayton-sys-960203.diff.gz
  419. clayton-sys-960203.tar.gz
  420. clayton.chown.sh
  421. clayton.install.sh
  422. clayton.lorder.sh
  423. clayton.make.sh
  424. gcc-2.7.2.tar.gz
  425. gcc-2.7.2+sys-types.diff.gz
  426. make.tar.gz
  427. make.diff.gz
  428. o Prepare the destination directory ready for installation.
  429. Firstly create many of the needed directories (some are
  430. created automatically later):
  431. $ for d in \
  432. /applications/psim \
  433. /applications/psim/bsd-root \
  434. /applications/psim/bsd-root/usr \
  435. /applications/psim/bsd-root/usr/share \
  436. /applications/psim/bsd-root/usr/share/doc \
  437. /applications/psim/bsd-root/usr/share/doc/psd \
  438. /applications/psim/bsd-root/usr/share/doc/psd/19.curses \
  439. /applications/psim/bsd-root/usr/include \
  440. /applications/psim/bsd-root/usr/lib \
  441. /applications/psim/powerpc-unknown-eabi \
  442. /applications/psim/powerpc-unknown-eabi/bin \
  443. ; \
  444. do test -d $d || mkdir $d ; done
  445. Next, link the BSD and GNU include directories together.
  446. GCC expects include files to be in one location while the
  447. bsd install expects them in a second. The link is in
  448. the direction below because bsd's install also insists on
  449. a directory (not a link) for its install destination.
  450. $ rm -rf /applications/psim/powerpc-unknown-eabi/include
  451. $ ln -s /applications/psim/bsd-root/usr/include \
  452. /applications/psim/powerpc-unknown-eabi/include
  453. $ ls -l /applications/psim/powerpc-unknown-eabi/include
  454. lrwxr-xr-x 1 cagney wheel 39 Mar 21 18:09
  455. /applications/psim/powerpc-unknown-eabi/include
  456. -> /applications/psim/bsd-root/usr/include
  457. o Build/install Berkeley make
  458. The tar archive make.tar.gz contains a recent snapshot
  459. of bmake from the NetBSD source tree. The notes below
  460. describe how to build/install it. If you have access
  461. to an even more recent version of bmake, use that.
  462. Unpack the source code:
  463. $ cd .../scratch
  464. $ gunzip < make.tar.gz | tar xf -
  465. $ cd make
  466. Apply the patch in make.diff.gz that fixes a minor
  467. problem with a build under Solaris (by now it should
  468. be fixed in the NetBSD-current source tree).
  469. $ gunzip < ../make.diff.gz | more
  470. $ gunzip < ../make.diff.gz | patch
  471. Build it
  472. $ make -f Makefile.boot 'CC=gcc -g -DPOSIX'
  473. With bmake built, install it into the target specific bin
  474. directory:
  475. $ cp bmake /applications/psim/powerpc-unknown-eabi/bin/make
  476. $ cd ..
  477. $ rm -rf make
  478. o Set up a number of wrapper scripts for bmake so that it works.
  479. In addition to needing BSD make the build process assumes
  480. a number of BSD specific commands. To get around this
  481. several wrapper scripts are available.
  482. powerpc-unknown-eabi-make (clayton.make.sh)
  483. Front end to Berkeley make setting it up for a
  484. cross compilation
  485. $ cp clayton.make.sh \
  486. /applications/psim/bin/powerpc-unknown-eabi-make
  487. $ chmod a+x \
  488. /applications/psim/bin/powerpc-unknown-eabi-make
  489. chown (clayton.chown.sh)
  490. Wrapper that does not do any thing.
  491. Avoids the need to be root when installing.
  492. $ cp clayton.chown.sh \
  493. /applications/psim/powerpc-unknown-eabi/bin/chown
  494. $ chmod a+x \
  495. /applications/psim/powerpc-unknown-eabi/bin/chown
  496. install (clayton.install.sh)
  497. Wrapper to strip away a number of bsd specific install
  498. arguments.
  499. $ cp clayton.install.sh \
  500. /applications/psim/powerpc-unknown-eabi/bin/install
  501. $ chmod a+x \
  502. /applications/psim/powerpc-unknown-eabi/bin/install
  503. lorder (clayton.lorder.sh)
  504. Tweaked lorder script that will use nm etc from
  505. binutils.
  506. $ cp clayton.lorder.sh \
  507. /applications/psim/powerpc-unknown-eabi/bin/lorder
  508. $ chmod a+x \
  509. /applications/psim/powerpc-unknown-eabi/bin/lorder
  510. printf (?)
  511. Some operating systems don't include the program
  512. printf. If you host doesn't have one, then a
  513. good source is the gnu sh-utils version.
  514. Again, if that program is missing, then I suggest
  515. installing it onto the powerpc specific program
  516. directory:
  517. /applications/psim/powerpc-unknown-eabi/bin
  518. o Unpack the bsd source code (if you haven't already)
  519. If you're short on disk space (like me) just unpack:
  520. sys, lib, share/mk, include, usr.sbin/config,
  521. usr.sbin/dbsym, gnu/lib/libg++/g++-include,
  522. usr.bin/lex
  523. Otherwize, assuming you have a CD-DRIVE:
  524. $ cd .../scratch
  525. $ mkdir bsd-src
  526. $ cd bsd-src
  527. $ for d in /cdrom/bsdisc_12_95_disc2/NetBSD-1.1/source/*11
  528. do
  529. echo $d
  530. cat $d/*.?? | gunzip | tar xf -
  531. done
  532. Flatten the directory structure a little.
  533. $ mv usr/src/* .
  534. $ rmdir usr/src usr
  535. $ cd ..
  536. o Apply the clayton (PowerPC) patches to your constructed
  537. tree.
  538. $ cd .../scratch
  539. $ cd bsd-src
  540. Diffs are applied using something like:
  541. $ gunzip < ../clayton-include-960312.diff.gz | patch -p1
  542. $ gunzip < ../clayton-lib-960203.diff.gz | patch -p1
  543. $ gunzip < ../clayton-sys-960203.diff.gz | patch -p1
  544. The patch to sys/dev/pci/ncr.c.rej might fail.
  545. The tar archives have a different problem, you need
  546. to remove the `src' prefix. I used
  547. $ ln -s . src
  548. $ gunzip < ../clayton-lib-960203.tar.gz | tar xvf -
  549. $ gunzip < ../clayton-sys-960203.tar.gz | tar xvf -
  550. So that src/xxx unpacked into ./xxx
  551. $ cd ..
  552. o install Berkeley make's include (mk) files.
  553. $ cd .../scrath
  554. $ cd bsd-src/share
  555. $ tar cf - mk | ( cd /applications/psim/bsd-root/usr/share \
  556. && tar xvf - )
  557. $ cd ../..
  558. o Install the include files
  559. $ cd .../scratch
  560. $ cd bsd-src/include
  561. $ powerpc-unknown-eabi-make install
  562. $ cd ../..
  563. o Install a few other include files.
  564. As discussed above in the section on building libnew,
  565. the build process can have chicken/egg problems. In the
  566. case of BSD's libc, it wants to use several include files
  567. (from the installed include directory) before they are
  568. installed. Just copy them in as seen below:
  569. $ cd .../scratch
  570. $ cd bsd-src
  571. $ cp gnu/lib/libg++/g++-include/values.h \
  572. /applications/psim/powerpc-unknown-eabi/include
  573. $ cp lib/libcurses/curses.h \
  574. /applications/psim/powerpc-unknown-eabi/include
  575. $ cd ..
  576. o Unpack/patch/build/install BINUTILS
  577. $ cd .../scratch
  578. $ gunzip < binutils-2.6.tar.gz | tar xf -
  579. gas (bfd) 2.6 didn't support the reading and writing of
  580. note sections. The patch binutils-2.6+note.diff.gz
  581. adds support for this. PowerPC/ELF boot files being loaded
  582. by OpenBoot ROM's should contain a PowerPC note section.
  583. $ cd .../scratch
  584. $ cd binutils-2.6/bfd
  585. $ gunzip < ../../binutils-2.6+note.diff.gz | more
  586. $ gunzip < ../../binutils-2.6+note.diff.gz | patch
  587. $ cd ../..
  588. Then continue with the build
  589. $ cd .../scratch
  590. $ cd binutils-2.6
  591. $ ./configure --target=powerpc-unknown-eabi \
  592. --prefix=/applications/psim
  593. $ make
  594. $ make install
  595. $ cd ..
  596. $ rm -rf binutils-2.6
  597. This has the intended side effect of partially populating
  598. the psim directory tree which makes follow on steps easier.
  599. o Unpack/patch/build/install GCC
  600. $ cd .../scratch
  601. $ gunzip < gcc-2.7.2.tar.gz | tar xf -
  602. $ cd gcc-2.7.2
  603. GCC-2.7.2 and the BSD include files have a conflicting type
  604. declaration. The patch below gets around this problem
  605. (it may still be applicable to more recent versions of
  606. GCC):
  607. $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | more
  608. $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | patch
  609. If your version of GCC includes the file ginclude/ppc-asm.h
  610. then you should install that header file into the directory:
  611. /applications/psim/powerpc-unknown-eabi/include. More
  612. recent versions of GCC expect this file to be installed:
  613. $ test -r ginclude/ppc-asm.h \
  614. && cp ginclude/ppc-asm.h \
  615. /applications/psim/powerpc-unknown-eabi/include
  616. Other than that, assuming the include files installed
  617. okay, the rest should be fine ....
  618. $ ./configure --target=powerpc-unknown-eabi \
  619. --prefix=/applications/psim
  620. $ make CC=gcc
  621. $ make CC=gcc install
  622. $ cd ..
  623. $ rm -rf gcc-2.7.2
  624. o Build/install the Berkeley library:
  625. $ cd .../scratch
  626. $ cd bsd-src/lib
  627. $ powerpc-unknown-eabi-make
  628. $ powerpc-unknown-eabi-make install
  629. $ cd ../..
  630. If you encounter problems check the following (each
  631. discussed above):
  632. o GCC and BSD have a common include
  633. directory
  634. o all the missing include files installed
  635. o all the wrapper programs installed
  636. o Build/run a simple BSD program
  637. $ cd .../scratch
  638. $ cd bsd-src/usr.bin/printenv
  639. $ powerpc-unknown-eabi-make
  640. $ powerpc-unknown-eabi-run printenv
  641. .
  642. .
  643. .
  644. ----------------------------------------------------------------------