18c2ecf20Sopenharmony_ci======================== 28c2ecf20Sopenharmony_ciThe PowerPC boot wrapper 38c2ecf20Sopenharmony_ci======================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciCopyright (C) Secret Lab Technologies Ltd. 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciPowerPC image targets compresses and wraps the kernel image (vmlinux) with 88c2ecf20Sopenharmony_cia boot wrapper to make it usable by the system firmware. There is no 98c2ecf20Sopenharmony_cistandard PowerPC firmware interface, so the boot wrapper is designed to 108c2ecf20Sopenharmony_cibe adaptable for each kind of image that needs to be built. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciThe boot wrapper can be found in the arch/powerpc/boot/ directory. The 138c2ecf20Sopenharmony_ciMakefile in that directory has targets for all the available image types. 148c2ecf20Sopenharmony_ciThe different image types are used to support all of the various firmware 158c2ecf20Sopenharmony_ciinterfaces found on PowerPC platforms. OpenFirmware is the most commonly 168c2ecf20Sopenharmony_ciused firmware type on general purpose PowerPC systems from Apple, IBM and 178c2ecf20Sopenharmony_ciothers. U-Boot is typically found on embedded PowerPC hardware, but there 188c2ecf20Sopenharmony_ciare a handful of other firmware implementations which are also popular. Each 198c2ecf20Sopenharmony_cifirmware interface requires a different image format. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciThe boot wrapper is built from the makefile in arch/powerpc/boot/Makefile and 228c2ecf20Sopenharmony_ciit uses the wrapper script (arch/powerpc/boot/wrapper) to generate target 238c2ecf20Sopenharmony_ciimage. The details of the build system is discussed in the next section. 248c2ecf20Sopenharmony_ciCurrently, the following image format targets exist: 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci ==================== ======================================================== 278c2ecf20Sopenharmony_ci cuImage.%: Backwards compatible uImage for older version of 288c2ecf20Sopenharmony_ci U-Boot (for versions that don't understand the device 298c2ecf20Sopenharmony_ci tree). This image embeds a device tree blob inside 308c2ecf20Sopenharmony_ci the image. The boot wrapper, kernel and device tree 318c2ecf20Sopenharmony_ci are all embedded inside the U-Boot uImage file format 328c2ecf20Sopenharmony_ci with boot wrapper code that extracts data from the old 338c2ecf20Sopenharmony_ci bd_info structure and loads the data into the device 348c2ecf20Sopenharmony_ci tree before jumping into the kernel. 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci Because of the series of #ifdefs found in the 378c2ecf20Sopenharmony_ci bd_info structure used in the old U-Boot interfaces, 388c2ecf20Sopenharmony_ci cuImages are platform specific. Each specific 398c2ecf20Sopenharmony_ci U-Boot platform has a different platform init file 408c2ecf20Sopenharmony_ci which populates the embedded device tree with data 418c2ecf20Sopenharmony_ci from the platform specific bd_info file. The platform 428c2ecf20Sopenharmony_ci specific cuImage platform init code can be found in 438c2ecf20Sopenharmony_ci `arch/powerpc/boot/cuboot.*.c`. Selection of the correct 448c2ecf20Sopenharmony_ci cuImage init code for a specific board can be found in 458c2ecf20Sopenharmony_ci the wrapper structure. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci dtbImage.%: Similar to zImage, except device tree blob is embedded 488c2ecf20Sopenharmony_ci inside the image instead of provided by firmware. The 498c2ecf20Sopenharmony_ci output image file can be either an elf file or a flat 508c2ecf20Sopenharmony_ci binary depending on the platform. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci dtbImages are used on systems which do not have an 538c2ecf20Sopenharmony_ci interface for passing a device tree directly. 548c2ecf20Sopenharmony_ci dtbImages are similar to simpleImages except that 558c2ecf20Sopenharmony_ci dtbImages have platform specific code for extracting 568c2ecf20Sopenharmony_ci data from the board firmware, but simpleImages do not 578c2ecf20Sopenharmony_ci talk to the firmware at all. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci PlayStation 3 support uses dtbImage. So do Embedded 608c2ecf20Sopenharmony_ci Planet boards using the PlanetCore firmware. Board 618c2ecf20Sopenharmony_ci specific initialization code is typically found in a 628c2ecf20Sopenharmony_ci file named arch/powerpc/boot/<platform>.c; but this 638c2ecf20Sopenharmony_ci can be overridden by the wrapper script. 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci simpleImage.%: Firmware independent compressed image that does not 668c2ecf20Sopenharmony_ci depend on any particular firmware interface and embeds 678c2ecf20Sopenharmony_ci a device tree blob. This image is a flat binary that 688c2ecf20Sopenharmony_ci can be loaded to any location in RAM and jumped to. 698c2ecf20Sopenharmony_ci Firmware cannot pass any configuration data to the 708c2ecf20Sopenharmony_ci kernel with this image type and it depends entirely on 718c2ecf20Sopenharmony_ci the embedded device tree for all information. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci treeImage.%; Image format for used with OpenBIOS firmware found 748c2ecf20Sopenharmony_ci on some ppc4xx hardware. This image embeds a device 758c2ecf20Sopenharmony_ci tree blob inside the image. 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci uImage: Native image format used by U-Boot. The uImage target 788c2ecf20Sopenharmony_ci does not add any boot code. It just wraps a compressed 798c2ecf20Sopenharmony_ci vmlinux in the uImage data structure. This image 808c2ecf20Sopenharmony_ci requires a version of U-Boot that is able to pass 818c2ecf20Sopenharmony_ci a device tree to the kernel at boot. If using an older 828c2ecf20Sopenharmony_ci version of U-Boot, then you need to use a cuImage 838c2ecf20Sopenharmony_ci instead. 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci zImage.%: Image format which does not embed a device tree. 868c2ecf20Sopenharmony_ci Used by OpenFirmware and other firmware interfaces 878c2ecf20Sopenharmony_ci which are able to supply a device tree. This image 888c2ecf20Sopenharmony_ci expects firmware to provide the device tree at boot. 898c2ecf20Sopenharmony_ci Typically, if you have general purpose PowerPC 908c2ecf20Sopenharmony_ci hardware then you want this image format. 918c2ecf20Sopenharmony_ci ==================== ======================================================== 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ciImage types which embed a device tree blob (simpleImage, dtbImage, treeImage, 948c2ecf20Sopenharmony_ciand cuImage) all generate the device tree blob from a file in the 958c2ecf20Sopenharmony_ciarch/powerpc/boot/dts/ directory. The Makefile selects the correct device 968c2ecf20Sopenharmony_citree source based on the name of the target. Therefore, if the kernel is 978c2ecf20Sopenharmony_cibuilt with 'make treeImage.walnut', then the build system will use 988c2ecf20Sopenharmony_ciarch/powerpc/boot/dts/walnut.dts to build treeImage.walnut. 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciTwo special targets called 'zImage' and 'zImage.initrd' also exist. These 1018c2ecf20Sopenharmony_citargets build all the default images as selected by the kernel configuration. 1028c2ecf20Sopenharmony_ciDefault images are selected by the boot wrapper Makefile 1038c2ecf20Sopenharmony_ci(arch/powerpc/boot/Makefile) by adding targets to the $image-y variable. Look 1048c2ecf20Sopenharmony_ciat the Makefile to see which default image targets are available. 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciHow it is built 1078c2ecf20Sopenharmony_ci--------------- 1088c2ecf20Sopenharmony_ciarch/powerpc is designed to support multiplatform kernels, which means 1098c2ecf20Sopenharmony_cithat a single vmlinux image can be booted on many different target boards. 1108c2ecf20Sopenharmony_ciIt also means that the boot wrapper must be able to wrap for many kinds of 1118c2ecf20Sopenharmony_ciimages on a single build. The design decision was made to not use any 1128c2ecf20Sopenharmony_ciconditional compilation code (#ifdef, etc) in the boot wrapper source code. 1138c2ecf20Sopenharmony_ciAll of the boot wrapper pieces are buildable at any time regardless of the 1148c2ecf20Sopenharmony_cikernel configuration. Building all the wrapper bits on every kernel build 1158c2ecf20Sopenharmony_cialso ensures that obscure parts of the wrapper are at the very least compile 1168c2ecf20Sopenharmony_citested in a large variety of environments. 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciThe wrapper is adapted for different image types at link time by linking in 1198c2ecf20Sopenharmony_cijust the wrapper bits that are appropriate for the image type. The 'wrapper 1208c2ecf20Sopenharmony_ciscript' (found in arch/powerpc/boot/wrapper) is called by the Makefile and 1218c2ecf20Sopenharmony_ciis responsible for selecting the correct wrapper bits for the image type. 1228c2ecf20Sopenharmony_ciThe arguments are well documented in the script's comment block, so they 1238c2ecf20Sopenharmony_ciare not repeated here. However, it is worth mentioning that the script 1248c2ecf20Sopenharmony_ciuses the -p (platform) argument as the main method of deciding which wrapper 1258c2ecf20Sopenharmony_cibits to compile in. Look for the large 'case "$platform" in' block in the 1268c2ecf20Sopenharmony_cimiddle of the script. This is also the place where platform specific fixups 1278c2ecf20Sopenharmony_cican be selected by changing the link order. 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciIn particular, care should be taken when working with cuImages. cuImage 1308c2ecf20Sopenharmony_ciwrapper bits are very board specific and care should be taken to make sure 1318c2ecf20Sopenharmony_cithe target you are trying to build is supported by the wrapper bits. 132