arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
[binutils-gdb.git] / sim / ppc / RUN
blob6c3cfefcb25bccaf0c037dfeb77d44e8cbe35da8
2                 PSIM - model the PowerPC environment
4     Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>.
6     ----------------------------------------------------------------------
8                         Running PSIM
10         This file describes how to run the program PSIM.
12         o       Walk through a number of examples from the
13                 pre-built tar archive psim-test.
15         o       Looks at the device tree used by PSIM.
17         o       Notes on building a programmer environment to
18                 use with PSIM (BSD/UEA and BUG/OEA)
21     ----------------------------------------------------------------------
24 RUNNING PSIM:
27 The compressed tar archive psim-test available from:
29         ftp://ftp.ci.com.au/pub/psim/psim-test-1.0.1.tar.gz
30 or      ftp://cambridge.cygnus.com/pub/psim/psim-test-1.0.1.tar.gz
32 contains a number of pre-built programs for running under PSIM.  Each
33 pre-built binary is built both big and little endian.  The suffixes
34 .be/.le (executables) .bo/.lo (object files) and .ba/.la (libraries)
35 are used.
38 To run one of these programs, use:
40         powerpc-unknown-eabi-run <image>
42 for instance:
44         powerpc-unknown-eabi-run psim-test/uea/envp
46 The program envp prints out your shells environment - very useful!
47 More generally psim is run as (this is part of the output from the -h
48 option):
50         psim [ <psim-option> ... ] <image> [ <image-arg> ... ]
52 Where
54         <image>       Name of the PowerPC program to run.
55                       This can either be a PowerPC binary or
56                       a text file containing a device tree
57                       specification.
58                       PSIM will attempt to determine from the
59                       specified <image> the intended emulation
60                       environment.
61                       If PSIM gets it wrong, the emulation
62                       environment can be specified using the
63                       `-e' option (described below).
65         <image-arg>   Argument to be passed to <image>
66                       These arguments will be passed to
67                       <image> (as standard C argv, argc)
68                       when <image> is started.
70         <psim-option> See below
72 The following are valid <psim-option>s:
74         -m <model>    Specify the processor to model (604)
75                       Selects the processor to use when
76                       modeling execution units.  Includes:
77                       604, 603 and 603e
79         -e <os-emul>  specify an OS or platform to model
80                       Can be any of the following:
81                       bug - OEA + MOTO BUG ROM calls
82                       netbsd - UEA + NetBSD system calls
83                       chirp - OEA + a few OpenBoot calls
85         -i            Print instruction counting statistics
87         -I            Print execution unit statistics
89         -r <size>     Set RAM size in bytes (OEA environments)
91         -t [!]<trace> Enable (disable) <trace> option
93         -o <spec>     add device <spec> to the device tree
95         -h -? -H      give more detailed usage
98 The `-H' option gives a long usage output.  This includes a complete
99 list of all the pre-configured devices.
102     ----------------------------------------------------------------------
105 RUNNING GDB:
108 If you built PSIM with gdb then the following is a quick start
109 tutorial.
111 At present GDB, if configured big-endian (say) unlike PSIM, does not
112 support the debugging of little endian binaries.  If you find that
113 your program won't run at all, make certain that GDB and your
114 program's endianness match.
117 The most important thing is that before you can run the simulator you
118 must enable it.  For the simulator, gdb is started like any program:
120         $ powerpc-unknown-eabi-gdb psim-test/uea/envp.be
122 Next the simulator is enabled.  The command `target sim' accepts the
123 same options as can be specified on the PSIM command line.
125         (gdb) target sim
127 To trace the communication between psim and gdb specify `target sim -t
128 gdb'.  Once enabled, the binary needs to be loaded, any breakpoints of
129 interest set, and the program run:
131         (gdb) load
132         (gdb) break main
133         (gdb) run
134         .
135         .
136         .
138 In addition, if you are wanting to run a program described by a device
139 tree you can `attach' to the simulation using (I assume that you have
140 applied the attach patch):
142         $ cd psim-test/tree
143         $ powerpc-unknown-eabi-gdb
144         (gdb) target sim
145         (gdb) attach device-tree
146         (gdb) run
148 Here GDB takes the programs initial state from the attached
149 device-tree instead of forcing initialisation.
152     ----------------------------------------------------------------------
155 PROFILING:
158 PSIM includes a number of performance monitoring (profiling)
159 facilities:
161         o       instruction frequency counting
163         o       execution unit modeling (records
164                 effective usage of units).
166         o       instruction cache performance
168 As discussed in the file INSTALL, each can be configured to individual
169 requirements.
172         -i      Enable instruction counting.
174                 The frequency of all instructions is tabulated.  In
175                 addition (f configured) the hit/miss rate of the
176                 instruction cache is output.
179         -I      Enable execution unit analysis.
181                 In addition to counting basic instructions also model
182                 the performance of the processors execution units
185         -m <processor>
187                 Select the processor to be modelled.
189                 For execution unit analysis specify the processor that
190                 is to be analysed.  By default the 604 is modelled
191                 however, support for other processors such as the
192                 603 and 603e is included.
194 The output from a performance run (on a P90) for the program
195 psim-test/profile/bench is below.  In this run psim was fairly
196 agressively configured (see the file INSTALL for compile time
197 configuration).
199         CPU #1 executed     41,994 AND instructions.
200         CPU #1 executed    519,785 AND Immediate instructions.
201         CPU #1 executed    680,058 Add instructions.
202         CPU #1 executed     41,994 Add Extended instructions.
203         CPU #1 executed    921,916 Add Immediate instructions.
204         CPU #1 executed    221,199 Add Immediate Carrying instructions.
205         CPU #1 executed    943,823 Add Immediate Shifted instructions.
206         CPU #1 executed    471,909 Add to Zero Extended instructions.
207         CPU #1 executed    571,915 Branch instructions.
208         CPU #1 executed  1,992,403 Branch Conditional instructions.
209         CPU #1 executed    571,910 Branch Conditional to Link Register instructions.
210         CPU #1 executed    320,431 Compare instructions.
211         CPU #1 executed    471,911 Compare Immediate instructions.
212         CPU #1 executed    145,867 Compare Logical instructions.
213         CPU #1 executed    442,414 Compare Logical Immediate instructions.
214         CPU #1 executed          1 Condition Register XOR instruction.
215         CPU #1 executed    103,873 Divide Word instructions.
216         CPU #1 executed    104,275 Divide Word Unsigned instructions.
217         CPU #1 executed    132,510 Extend Sign Byte instructions.
218         CPU #1 executed    178,895 Extend Sign Half Word instructions.
219         CPU #1 executed    871,920 Load Word and Zero instructions.
220         CPU #1 executed     41,994 Move From Condition Register instructions.
221         CPU #1 executed    100,005 Move from Special Purpose Register instructions.
222         CPU #1 executed    100,002 Move to Special Purpose Register instructions.
223         CPU #1 executed    804,619 Multiply Low Word instructions.
224         CPU #1 executed    421,201 OR instructions.
225         CPU #1 executed    471,910 OR Immediate instructions.
226         CPU #1 executed  1,292,020 Rotate Left Word Immediate then AND with Mask instructions.
227         CPU #1 executed    663,613 Shift Left Word instructions.
228         CPU #1 executed  1,151,564 Shift Right Algebraic Word Immediate instructions.
229         CPU #1 executed    871,922 Store Word instructions.
230         CPU #1 executed    100,004 Store Word with Update instructions.
231         CPU #1 executed    887,804 Subtract From instructions.
232         CPU #1 executed     83,988 Subtract From Immediate Carrying instructions.
233         CPU #1 executed          1 System Call instruction.
234         CPU #1 executed    207,746 XOR instructions.
235         
236         CPU #1 executed 23,740,856 cycles.
237         CPU #1 executed 10,242,780 stalls waiting for data.
238         CPU #1 executed          1 stall waiting for a function unit.
239         CPU #1 executed          1 stall waiting for serialization.
240         CPU #1 executed  1,757,900 times a write-back slot was unavailable.
241         CPU #1 executed  1,088,135 branches.
242         CPU #1 executed  2,048,093 conditional branches fell through.
243         CPU #1 executed  1,088,135 successful branch predictions.
244         CPU #1 executed    904,268 unsuccessful branch predictions.
245         CPU #1 executed    742,557 branch if the condition is FALSE conditional branches.
246         CPU #1 executed  1,249,846 branch if the condition is TRUE conditional branches.
247         CPU #1 executed    571,910 branch always conditional branches.
248         CPU #1 executed  9,493,653 1st single cycle integer functional unit instructions.
249         CPU #1 executed  1,220,900 2nd single cycle integer functional unit instructions.
250         CPU #1 executed  1,254,768 multiple cycle integer functional unit instructions.
251         CPU #1 executed  1,843,846 load/store functional unit instructions.
252         CPU #1 executed  3,136,229 branch functional unit instructions.
253         CPU #1 executed 16,949,396 instructions that were accounted for in timing info.
254         CPU #1 executed    871,920 data reads.
255         CPU #1 executed    971,926 data writes.
256         CPU #1 executed        221 icache misses.
257         CPU #1 executed 16,949,396 instructions in total.
258         
259         Simulator speed was 250,731 instructions/second
262     ----------------------------------------------------------------------
265 PSIM CONFIGURATION - THE DEVICE TREE
268 Internally PSIM's configuration is controlled by a tree data
269 structure.  This structure, created at run-time, intentionally
270 resembles the device tree used by OpenBoot firmware to describe a
271 machines hardware configuration.
273 PSIM can either create its device tree using a builtin emulation or
274 from one read in from a file.
276 During startup, the device tree is created using the following steps:
278         o       Initial empty tree is created
280         o       Any tree entry options specified on the
281                 command line are merged in (the -o <entry>
282                 option is used).
284                 It should be pointed out that most of the
285                 command line options (eg -r, -e, -m, -t
286                 are all just short hand for corresponding
287                 -o options).
289         o       If the specified program is a device tree spec, that
290                 is loaded.
292                 If the specified program is a text file it is assumed
293                 that that file contains a further specification of the
294                 simulators device tree.  That tree is loaded and
295                 merged with the current tree options.
297         o       The selected emulation fills out any remaining details.
299                 By this stage the emulation environment that the program
300                 needs will either be specified in the device tree
301                 (through the -e option) or determined from the
302                 characteristics of the binary.
304                 The selected emulation will then fill out any missing
305                 nodes in the device tree.
307 Most importantly earlier additions to the tree are not overridden by
308 later additions.  Thus, command line options override information
309 found in the program file and both override any builtin emulation
310 entries.
312 The following is a summary of the most useful runtime configuration
313 options:
315         -e <os-emul>
316         -o '/openprom/options/os-emul <os-emul>'
318                 Run program using the <emulation> run-time
319                 environment.
321         -r <ram-size>
322         -o '/openprom/options/oea-memory-size <ram-size>'
324                 Set the size of the first bank of memory
325                 (RAM from address 0 up).
327         -t print-device-tree
328         -o '/openprom/trace/print-device-tree 1'
330         -t dump-device-tree
331         -o '/openprom/trace/dump-device-tree 1'
333                 Print out the device tree once it has been fully
334                 populated. For dump-device-tree, exit simulator after
335                 dumping the tree.
337                 PSIM is able to reload the dumped device tree.
339                 The format of the dumped tree is under development.
341         -o '/openprom/options/smp <N>'
343                 Enable <N> processors for the simulation run.
344                 See the directory psim-test/oea for an example.
346         -o '/openprom/options/alignment <N>'
348                 Where <N> is 1 - nonstrict or 2 - strict.
349                 Specify if the missaligned access are allowed
350                 (non-strict) or result in an alignment exception
351                 (strict).
353 Devices (if included in the file device_table.c) can also be specified
354 in a similar way.  For instance, to add a second serial port, a
355 command like:
357         -o '/iobus@0x400000/console@0x000010'
359 would create a `console' device at offset 0x10 within the `iobus' at
360 memory address 0x400000.
362 For more detailed information on device specifiers see the notes on
363 the function dump_device_tree in the file device.c (found in the
364 source code).
367     ----------------------------------------------------------------------
370 BUILDING A BUG/OEA DEVELOPMENT ENVIRONMENT
373 Background:
376 Included in many PowerPC systems is Motorola's BUG monitor.  This
377 monitor includes, for client programs, a set of services that allow
378 that program to interact with hardware devices such as the console using
379 a simple system call interface.
381 PSIM is able to emulate a number of the services (including the
382 console IO calls).  If additional services are needed they can easily
383 be added.
385 Cygnus support's newlib library includes includes an interface to the
386 MOTO BUG services.  The notes below discuss how I both built and run
387 programs compiled using this library on PSIM.
389 The only confusing part about building a development environment based
390 around newlib/binutils/gcc is a chicken/egg problem with include
391 files:
392                 
393         For GCC to build, a fairly complete set of include
394         files must be installed but newlib won't install its
395         include files until it has been built with gcc ...
397 I get around this by installing the problematic include files by hand.
400 Preparation:
403 The following files are needed:
405 From your favorite FTP site, the sources to gas/ld and gcc - mine
406 happens to be archie.au :
408         ftp://archie.au/gnu/binutils-2.6.tar.gz
409         ftp://archie.au/gnu/gcc-2.7.2.tar.gz
411 From ftp://ftp.cygnus.com/pub/newlib the source code to a library:
413         ftp://ftp.cygnus.com/pub/newlib/newlib-1.7.0.tar.gz
415 From ftp://ftp.ci.com.au/pub/psim some minor patches and updates to
416 the above library:
418         ftp://ftp.ci.com.au/pub/psim/newlib-1.7.0+float+ppc-asm.tar.gz
419         ftp://ftp.ci.com.au/pub/psim/newlib-1.7.0+ppc-fix.diff.gz
420         ftp://ftp.ci.com.au/pub/psim/binutils-2.6+note.diff.gz
422 In addition you'll need to decide where you will be installing the
423 development environment.  You will notice that in the below I install
424 things well away /usr/local instead installing everything under its
425 own directory in /applications.
428 Method:
431 These notes are based on an installation performed on a Sun-OS-4/SPARC
432 host.  For other hosts and other configurations, the below should be
433 considered as a guideline only.
436         o       Sanity check
438                 $ cd .../scratch        # your scratch directory
439                 $ ls -1
440                 binutils-2.6.tar.gz
441                 binutils-2.6+note.diff.gz
442                 gcc-2.7.2,tar.gz
443                 newlib-1.7.0+float+ppc-asm.tar.gz
444                 newlib-1.7.0+ppc-fix.diff.gz
445                 newlib-1.7.0.tar.gz
448         o       Unpack/build/install binutils
450                 This is done first so that there is a gas/ld ready
451                 for the building of GCC and NEWLIB.
453                 $ cd .../scratch
454                 $ gunzip < binutils-2.6.tar.gz | tar xf -
455                 $ cd binutils-2.6
457                 Optionally apply the note patch
459                 $ gunzip ../binutils-2.6+note.diff.gz | patch
461                 Then continue with the build
463                 $ ./configure --target=powerpc-unknown-eabi \
464                               --prefix=/applications/psim
465                 $ make
466                 $ make install
467                 $ cd ..
468                 $ rm -rf binutils-2.6
470                 This also creates much of the installation directory
471                 tree.
474         o       Unpack newlib, install the include files so that they
475                 are ready for GCC's build.
477                 $ cd .../scratch
478                 $ gunzip < newlib-1.7.0.tar.gz | tar xf -
480                 New lib-1.7.0 had a few minor bugs (fixed in current):
481                 the header files float.h and ppc-asm.h were missing;
482                 the configure and Makefile's for the rs6000 (ppc) directory
483                 contained typos:
485                 $ cd .../scratch
486                 $ cd newlib-1.7.0
487                 $ gunzip < ../newlib-1.7.0+float+ppc-asm.tar.gz | tar xvf -
488                 $ gunzip < ../newlib-1.7.0+ppc-fix.diff.gz | patch -p1
489                 
490                 Finally copy the include files to where GCC will see them:
492                 $ cd .../scratch
493                 $ cd newlib-1.7.0/newlib/libc
494                 $ tar cf - include | \
495                    ( cd /applications/psim/powerpc-unknown-eabi && tar xf - )
498         o       Unpack/build gcc
500                 $ cd .../scratch
501                 $ gunzip < gcc-2.7.2,tar.gz | tar xf -
502                 $ cd gcc-2.7.2
503                 $ ./configure --target=powerpc-unknown-eabi \
504                               --prefix=/applications/psim
505                 $ make
506                 $ make install
507                 $ cd ..
508                 $ rm -rf gcc-2.7.2
510                 Gcc likes to install its own dummy version of float that
511                 just returns an error.
513                 $ more /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h
514                 $ rm /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h
517         o       Finish building/installing newlib
519                 $ cd .../scratch
520                 $ cd newlib-1.7.0
521                 $ ./configure --target=powerpc-unknown-eabi \
522                               --prefix=/applications/psim
524                 Your path will need to include the recently installed
525                 gas/gcc when building.  Either add it to your path or
526                 use:
528                 $ PATH=/applications/psim/bin:$PATH make
529                 $ PATH=/applications/psim/bin:$PATH make install
532         o       Finally, test out the build
534                 $ cat hello.c
535                 main()
536                 {
537                   printf("hello world\n");
538                 }
540                 The binary is linked with an entry point less than 0x100000
541                 (1mb) so that psim will recognize the binary as needing
542                 the BUG/OEA instead of the BSD/UEA runtime environment.
544                 $ powerpc-unknown-eabi-gcc -v -o hello \
545                     -Wl,-Ttext,0x4000,-Tdata,0x10000 \
546                     /applications/psim/powerpc-unknown-eabi/lib/mvme-crt0.o \
547                     hello.c \
548                     -lc -lmvme
549                 $ powerpc-unknown-eabi-objdump -h hello
550                 $ powerpc-unknown-eabi-run hello
552                 It is also possible to force psim to use a specific
553                 run-time environment using the -e option vis:
555                 $ powerpc-unknown-eabi-run -e bug hello
560     ----------------------------------------------------------------------
563 BUILDING A BSD/UEA DEVELOPMENT ENVIRONMENT
566 Background:
569 For a UEA to be useful it needs a supporting run-time environment.
570 PSIM implements a runtime environment based on the NetBSD system call
571 interface.
573 More than any thing, this user level emulation was the first
574 implemented because I happened to have the NetBSD source code lying
575 around.
578 Preparation:
581 This requires the NetBSD-1.1 source tree online.  It can either be
582 obtained vi ftp:
584         try http://www.netbsd.org  or  ftp://ftp.netbsd.org
586 Alternatively obtain one of the NetBSD cdrom's.  Patches to this source
587 tree that fill out much of the PowerPC code are available in:
589         ftp://ftp.ci.com.au/pub/clayton
591 Fetch everything in that directory - diffs, tar archives and scripts.
592 In addition patches to the bintuils and gcc are in:
594         ftp://ftp.ci.com.au/pub/psim/binutils-2.6+note.diff.gz
595         ftp://ftp.ci.com.au/pub/psim/gcc-2.7.2+sys-types.diff.gz
597 while the compiler (gcc) and assember (binutils) can be found at your
598 favorite gnu ftp site.  I used versions:
600         gcc-2.7.2.tar.gz
601         binutils-2.6.tar.gz
606 Method:
609 These notes are based on an installation performed on a Solaris2/x86
610 host.  For other hosts and other configurations, the below should be
611 considered as a guideline only.
614         o       Sanity check
616                 I assume that you have already obtained the NetBSD-1.1 source
617                 code and unpacked it into the directory bsd-src.  While the
618                 full NetBSD source tree may not be needed, things are easier
619                 if it is all online.
621                 $ cd .../scratch
622                 $ ls -1
623                 binutils-2.6.tar.gz
624                 binutils-2.6+note.diff.gz
625                 clayton-include-960203.diff.gz
626                 clayton-lib-960203.diff.gz
627                 clayton-lib-960203.tar.gz
628                 clayton-sys-960203.diff.gz
629                 clayton-sys-960203.tar.gz
630                 clayton.chown.sh
631                 clayton.install.sh
632                 clayton.lorder.sh
633                 clayton.make.sh
634                 gcc-2.7.2.tar.gz
635                 gcc-2.7.2+sys-types.diff.gz
636                 make.tar.gz
637                 make.diff.gz
640         o       Prepare the destination directory ready for installation.
642                 Firstly create many of the needed directories (some are
643                 created automatically later):
645                 $ for d in \
646                     /applications/psim \
647                     /applications/psim/bsd-root \
648                     /applications/psim/bsd-root/usr \
649                     /applications/psim/bsd-root/usr/share \
650                     /applications/psim/bsd-root/usr/share/doc \
651                     /applications/psim/bsd-root/usr/share/doc/psd \
652                     /applications/psim/bsd-root/usr/share/doc/psd/19.curses \
653                     /applications/psim/bsd-root/usr/include \
654                     /applications/psim/bsd-root/usr/lib \
655                     /applications/psim/powerpc-unknown-eabi \
656                     /applications/psim/powerpc-unknown-eabi/bin \
657                     ; \
658                   do test -d $d || mkdir $d ; done
660                 Next, link the BSD and GNU include directories together.
661                 GCC expects include files to be in one location while the
662                 bsd install expects them in a second.  The link is in
663                 the direction below because bsd's install also insists on
664                 a directory (not a link) for its install destination.
666                 $ rm -rf /applications/psim/powerpc-unknown-eabi/include
667                 $ ln -s /applications/psim/bsd-root/usr/include \
668                     /applications/psim/powerpc-unknown-eabi/include
670                 $ ls -l /applications/psim/powerpc-unknown-eabi/include
671                 lrwxr-xr-x  1 cagney  wheel  39 Mar 21 18:09
672                 /applications/psim/powerpc-unknown-eabi/include
673                 -> /applications/psim/bsd-root/usr/include
676         o       Build/install Berkeley make
678                 The tar archive make.tar.gz contains a recent snapshot
679                 of bmake from the NetBSD source tree.  The notes below
680                 describe how to build/install it.  If you have access
681                 to an even more recent version of bmake, use that.
683                 Unpack the source code:
685                 $ cd .../scratch
686                 $ gunzip < make.tar.gz | tar xf -
687                 $ cd make
689                 Apply the patch in make.diff.gz that fixes a minor
690                 problem with a build under Solaris (by now it should
691                 be fixed in the NetBSD-current source tree).
693                 $ gunzip < ../make.diff.gz | more
694                 $ gunzip < ../make.diff.gz | patch
696                 Build it
698                 $ make -f Makefile.boot 'CC=gcc -g -DPOSIX'
700                 With bmake built, install it into the target specific bin
701                 directory:
703                 $ cp bmake /applications/psim/powerpc-unknown-eabi/bin/make
704                 $ cd ..
705                 $ rm -rf make
708         o       Set up a number of wrapper scripts for bmake so that it works.
710                 In addition to needing BSD make the build process assumes
711                 a number of BSD specific commands.  To get around this
712                 several wrapper scripts are available.
714                 powerpc-unknown-eabi-make (clayton.make.sh)
716                         Front end to Berkeley make setting it up for a
717                         cross compilation
719                         $ cp clayton.make.sh \
720                           /applications/psim/bin/powerpc-unknown-eabi-make
721                         $ chmod a+x \
722                           /applications/psim/bin/powerpc-unknown-eabi-make
724                 chown (clayton.chown.sh)
726                         Wrapper that does not do any thing.
727                         Avoids the need to be root when installing.
729                         $ cp clayton.chown.sh \
730                           /applications/psim/powerpc-unknown-eabi/bin/chown
731                         $ chmod a+x \
732                           /applications/psim/powerpc-unknown-eabi/bin/chown
734                 install (clayton.install.sh)
736                         Wrapper to strip away a number of bsd specific install
737                         arguments.
739                         $ cp clayton.install.sh \
740                           /applications/psim/powerpc-unknown-eabi/bin/install
741                         $ chmod a+x \
742                           /applications/psim/powerpc-unknown-eabi/bin/install
744                 lorder (clayton.lorder.sh)
746                         Tweaked lorder script that will use nm etc from
747                         binutils.
749                         $ cp clayton.lorder.sh \
750                           /applications/psim/powerpc-unknown-eabi/bin/lorder
751                         $ chmod a+x \
752                           /applications/psim/powerpc-unknown-eabi/bin/lorder
755                 printf (?)
757                         Some operating systems don't include the program
758                         printf.  If you host doesn't have one, then a
759                         good source is the gnu sh-utils version.
761                         Again, if that program is missing, then I suggest
762                         installing it onto the powerpc specific program
763                         directory:
765                         /applications/psim/powerpc-unknown-eabi/bin
768         o       Unpack the bsd source code (if you haven't already)
770                 If you're short on disk space (like me) just unpack:
772                         sys, lib, share/mk, include, usr.sbin/config,
773                         usr.sbin/dbsym, gnu/lib/libg++/g++-include,
774                         usr.bin/lex
776                 Otherwize, assuming you have a CD-DRIVE:
778                 $ cd .../scratch
779                 $ mkdir bsd-src
780                 $ cd bsd-src
781                 $ for d in /cdrom/bsdisc_12_95_disc2/NetBSD-1.1/source/*11
782                   do
783                     echo $d
784                     cat $d/*.?? | gunzip | tar xf -
785                   done
787                 Flatten the directory structure a little.
789                 $ mv usr/src/* .
790                 $ rmdir usr/src usr
791                 $ cd ..
794         o       Apply the clayton (PowerPC) patches to your constructed
795                 tree.
797                 $ cd .../scratch
798                 $ cd bsd-src
799                 
800                 Diffs are applied using something like:
802                 $ gunzip < ../clayton-include-960312.diff.gz | patch -p1
803                 $ gunzip < ../clayton-lib-960203.diff.gz | patch -p1
804                 $ gunzip < ../clayton-sys-960203.diff.gz | patch -p1
806                 The patch to sys/dev/pci/ncr.c.rej might fail.
808                 The tar archives have a different problem, you need
809                 to remove the `src' prefix.  I used
811                 $ ln -s . src
812                 $ gunzip < ../clayton-lib-960203.tar.gz | tar xvf -
813                 $ gunzip < ../clayton-sys-960203.tar.gz | tar xvf -
815                 So that src/xxx unpacked into ./xxx
817                 $ cd ..
820         o       install Berkeley make's include (mk) files.
822                 $ cd .../scrath
823                 $ cd bsd-src/share
824                 $ tar cf - mk | ( cd /applications/psim/bsd-root/usr/share \
825                      && tar xvf - )
826                 $ cd ../..
829         o       Install the include files
831                 $ cd .../scratch
832                 $ cd bsd-src/include
833                 $ powerpc-unknown-eabi-make install
834                 $ cd ../..
835                 
837         o       Install a few other include files.
839                 As discussed above in the section on building libnew,
840                 the build process can have chicken/egg problems.  In the
841                 case of BSD's libc, it wants to use several include files
842                 (from the installed include directory) before they are
843                 installed.  Just copy them in as seen below:
845                 $ cd .../scratch
846                 $ cd bsd-src
847                 $ cp gnu/lib/libg++/g++-include/values.h \
848                     /applications/psim/powerpc-unknown-eabi/include
849                 $ cp lib/libcurses/curses.h \
850                     /applications/psim/powerpc-unknown-eabi/include
851                 $ cd ..
854         o       Unpack/patch/build/install BINUTILS
856                 $ cd .../scratch
857                 $ gunzip < binutils-2.6.tar.gz | tar xf -
859                 gas (bfd) 2.6 didn't support the reading and writing of
860                 note sections.  The patch binutils-2.6+note.diff.gz
861                 adds support for this.  PowerPC/ELF boot files being loaded
862                 by OpenBoot ROM's should contain a PowerPC note section.
864                 $ cd .../scratch
865                 $ cd binutils-2.6/bfd
866                 $ gunzip < ../../binutils-2.6+note.diff.gz | more
867                 $ gunzip < ../../binutils-2.6+note.diff.gz | patch
868                 $ cd ../..
870                 Then continue with the build
872                 $ cd .../scratch
873                 $ cd binutils-2.6
874                 $ ./configure --target=powerpc-unknown-eabi \
875                               --prefix=/applications/psim
876                 $ make
877                 $ make install
878                 $ cd ..
879                 $ rm -rf binutils-2.6
881                 This has the intended side effect of partially populating
882                 the psim directory tree which makes follow on steps easier.
885         o       Unpack/patch/build/install GCC
887                 $ cd .../scratch
888                 $ gunzip < gcc-2.7.2.tar.gz | tar xf -
889                 $ cd gcc-2.7.2
891                 GCC-2.7.2 and the BSD include files have a conflicting type
892                 declaration.  The patch below gets around this problem
893                 (it may still be applicable to more recent versions of
894                 GCC):
896                 $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | more
897                 $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | patch
899                 If your version of GCC includes the file ginclude/ppc-asm.h
900                 then you should install that header file into the directory:
901                 /applications/psim/powerpc-unknown-eabi/include.  More
902                 recent versions of GCC expect this file to be installed:
904                 $ test -r ginclude/ppc-asm.h \
905                   && cp ginclude/ppc-asm.h \
906                      /applications/psim/powerpc-unknown-eabi/include
908                 Other than that, assuming the include files installed
909                 okay, the rest should be fine ....
911                 $ ./configure --target=powerpc-unknown-eabi \
912                               --prefix=/applications/psim
913                 $ make CC=gcc
914                 $ make CC=gcc install
915                 $ cd ..
916                 $ rm -rf gcc-2.7.2
919         o       Build/install the Berkeley library:
921                 $ cd .../scratch
922                 $ cd bsd-src/lib
923                 $ powerpc-unknown-eabi-make
924                 $ powerpc-unknown-eabi-make install
925                 $ cd ../..
927                 If you encounter problems check the following (each
928                 discussed above):
930                         o       GCC and BSD have a common include
931                                 directory
933                         o       all the missing include files installed
935                         o       all the wrapper programs installed
938         o       Build/run a simple BSD program
940                 $ cd .../scratch
941                 $ cd bsd-src/usr.bin/printenv
942                 $ powerpc-unknown-eabi-make
943                 $ powerpc-unknown-eabi-run printenv
944                 .
945                 .
946                 .
949     ----------------------------------------------------------------------