^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) The PowerPC boot wrapper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Copyright (C) Secret Lab Technologies Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) PowerPC image targets compresses and wraps the kernel image (vmlinux) with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) a boot wrapper to make it usable by the system firmware. There is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) standard PowerPC firmware interface, so the boot wrapper is designed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) be adaptable for each kind of image that needs to be built.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) The boot wrapper can be found in the arch/powerpc/boot/ directory. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Makefile in that directory has targets for all the available image types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) The different image types are used to support all of the various firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) interfaces found on PowerPC platforms. OpenFirmware is the most commonly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) used firmware type on general purpose PowerPC systems from Apple, IBM and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) others. U-Boot is typically found on embedded PowerPC hardware, but there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) are a handful of other firmware implementations which are also popular. Each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) firmware interface requires a different image format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The boot wrapper is built from the makefile in arch/powerpc/boot/Makefile and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) it uses the wrapper script (arch/powerpc/boot/wrapper) to generate target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) image. The details of the build system is discussed in the next section.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Currently, the following image format targets exist:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ==================== ========================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) cuImage.%: Backwards compatible uImage for older version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) U-Boot (for versions that don't understand the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) tree). This image embeds a device tree blob inside
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) the image. The boot wrapper, kernel and device tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) are all embedded inside the U-Boot uImage file format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) with boot wrapper code that extracts data from the old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bd_info structure and loads the data into the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) tree before jumping into the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Because of the series of #ifdefs found in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bd_info structure used in the old U-Boot interfaces,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) cuImages are platform specific. Each specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) U-Boot platform has a different platform init file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) which populates the embedded device tree with data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) from the platform specific bd_info file. The platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) specific cuImage platform init code can be found in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) `arch/powerpc/boot/cuboot.*.c`. Selection of the correct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) cuImage init code for a specific board can be found in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) the wrapper structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) dtbImage.%: Similar to zImage, except device tree blob is embedded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) inside the image instead of provided by firmware. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) output image file can be either an elf file or a flat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) binary depending on the platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dtbImages are used on systems which do not have an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) interface for passing a device tree directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) dtbImages are similar to simpleImages except that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) dtbImages have platform specific code for extracting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) data from the board firmware, but simpleImages do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) talk to the firmware at all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) PlayStation 3 support uses dtbImage. So do Embedded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) Planet boards using the PlanetCore firmware. Board
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) specific initialization code is typically found in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) file named arch/powerpc/boot/<platform>.c; but this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) can be overridden by the wrapper script.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) simpleImage.%: Firmware independent compressed image that does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) depend on any particular firmware interface and embeds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) a device tree blob. This image is a flat binary that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) can be loaded to any location in RAM and jumped to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Firmware cannot pass any configuration data to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) kernel with this image type and it depends entirely on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) the embedded device tree for all information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) treeImage.%; Image format for used with OpenBIOS firmware found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) on some ppc4xx hardware. This image embeds a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) tree blob inside the image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) uImage: Native image format used by U-Boot. The uImage target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) does not add any boot code. It just wraps a compressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) vmlinux in the uImage data structure. This image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) requires a version of U-Boot that is able to pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) a device tree to the kernel at boot. If using an older
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) version of U-Boot, then you need to use a cuImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) zImage.%: Image format which does not embed a device tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) Used by OpenFirmware and other firmware interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) which are able to supply a device tree. This image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) expects firmware to provide the device tree at boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) Typically, if you have general purpose PowerPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) hardware then you want this image format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ==================== ========================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) Image types which embed a device tree blob (simpleImage, dtbImage, treeImage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) and cuImage) all generate the device tree blob from a file in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) arch/powerpc/boot/dts/ directory. The Makefile selects the correct device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) tree source based on the name of the target. Therefore, if the kernel is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) built with 'make treeImage.walnut', then the build system will use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) arch/powerpc/boot/dts/walnut.dts to build treeImage.walnut.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) Two special targets called 'zImage' and 'zImage.initrd' also exist. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) targets build all the default images as selected by the kernel configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Default images are selected by the boot wrapper Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) (arch/powerpc/boot/Makefile) by adding targets to the $image-y variable. Look
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) at the Makefile to see which default image targets are available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) How it is built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) arch/powerpc is designed to support multiplatform kernels, which means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) that a single vmlinux image can be booted on many different target boards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) It also means that the boot wrapper must be able to wrap for many kinds of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) images on a single build. The design decision was made to not use any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) conditional compilation code (#ifdef, etc) in the boot wrapper source code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) All of the boot wrapper pieces are buildable at any time regardless of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) kernel configuration. Building all the wrapper bits on every kernel build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) also ensures that obscure parts of the wrapper are at the very least compile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) tested in a large variety of environments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) The wrapper is adapted for different image types at link time by linking in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) just the wrapper bits that are appropriate for the image type. The 'wrapper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) script' (found in arch/powerpc/boot/wrapper) is called by the Makefile and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) is responsible for selecting the correct wrapper bits for the image type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) The arguments are well documented in the script's comment block, so they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) are not repeated here. However, it is worth mentioning that the script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) uses the -p (platform) argument as the main method of deciding which wrapper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) bits to compile in. Look for the large 'case "$platform" in' block in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) middle of the script. This is also the place where platform specific fixups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) can be selected by changing the link order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) In particular, care should be taken when working with cuImages. cuImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) wrapper bits are very board specific and care should be taken to make sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) the target you are trying to build is supported by the wrapper bits.