요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
========================
The PowerPC boot wrapper
========================
Copyright (C) Secret Lab Technologies Ltd.
PowerPC image targets compresses and wraps the kernel image (vmlinux) with
a boot wrapper to make it usable by the system firmware. There is no
standard PowerPC firmware interface, so the boot wrapper is designed to
be adaptable for each kind of image that needs to be built.
The boot wrapper can be found in the arch/powerpc/boot/ directory. The
Makefile in that directory has targets for all the available image types.
The different image types are used to support all of the various firmware
interfaces found on PowerPC platforms. OpenFirmware is the most commonly
used firmware type on general purpose PowerPC systems from Apple, IBM and
others. U-Boot is typically found on embedded PowerPC hardware, but there
are a handful of other firmware implementations which are also popular. Each
firmware interface requires a different image format.
The boot wrapper is built from the makefile in arch/powerpc/boot/Makefile and
it uses the wrapper script (arch/powerpc/boot/wrapper) to generate target
image. The details of the build system is discussed in the next section.
Currently, the following image format targets exist:
==================== ========================================================
cuImage.%: Backwards compatible uImage for older version of
U-Boot (for versions that don't understand the device
tree). This image embeds a device tree blob inside
the image. The boot wrapper, kernel and device tree
are all embedded inside the U-Boot uImage file format
with boot wrapper code that extracts data from the old
bd_info structure and loads the data into the device
tree before jumping into the kernel.
Because of the series of #ifdefs found in the
bd_info structure used in the old U-Boot interfaces,
cuImages are platform specific. Each specific
U-Boot platform has a different platform init file
which populates the embedded device tree with data
from the platform specific bd_info file. The platform
specific cuImage platform init code can be found in
`arch/powerpc/boot/cuboot.*.c`. Selection of the correct
cuImage init code for a specific board can be found in
the wrapper structure.
dtbImage.%: Similar to zImage, except device tree blob is embedded
inside the image instead of provided by firmware. The
output image file can be either an elf file or a flat
binary depending on the platform.
dtbImages are used on systems which do not have an
interface for passing a device tree directly.
dtbImages are similar to simpleImages except that
dtbImages have platform specific code for extracting
data from the board firmware, but simpleImages do not
talk to the firmware at all.
PlayStation 3 support uses dtbImage. So do Embedded
Planet boards using the PlanetCore firmware. Board
specific initialization code is typically found in a
file named arch/powerpc/boot/<platform>.c; but this
can be overridden by the wrapper script.
simpleImage.%: Firmware independent compressed image that does not
depend on any particular firmware interface and embeds
a device tree blob. This image is a flat binary that
can be loaded to any location in RAM and jumped to.
Firmware cannot pass any configuration data to the
kernel with this image type and it depends entirely on
the embedded device tree for all information.
treeImage.%; Image format for used with OpenBIOS firmware found
on some ppc4xx hardware. This image embeds a device
tree blob inside the image.
uImage: Native image format used by U-Boot. The uImage target
does not add any boot code. It just wraps a compressed
vmlinux in the uImage data structure. This image
requires a version of U-Boot that is able to pass
a device tree to the kernel at boot. If using an older
version of U-Boot, then you need to use a cuImage
instead.
zImage.%: Image format which does not embed a device tree.
Used by OpenFirmware and other firmware interfaces
which are able to supply a device tree. This image
expects firmware to provide the device tree at boot.
Typically, if you have general purpose PowerPC
hardware then you want this image format.
==================== ========================================================
Image types which embed a device tree blob (simpleImage, dtbImage, treeImage,
and cuImage) all generate the device tree blob from a file in the
arch/powerpc/boot/dts/ directory. The Makefile selects the correct device
tree source based on the name of the target. Therefore, if the kernel is
built with 'make treeImage.walnut', then the build system will use
arch/powerpc/boot/dts/walnut.dts to build treeImage.walnut.
Two special targets called 'zImage' and 'zImage.initrd' also exist. These
targets build all the default images as selected by the kernel configuration.
Default images are selected by the boot wrapper Makefile
(arch/powerpc/boot/Makefile) by adding targets to the $image-y variable. Look
at the Makefile to see which default image targets are available.
How it is built
---------------
arch/powerpc is designed to support multiplatform kernels, which means
that a single vmlinux image can be booted on many different target boards.
It also means that the boot wrapper must be able to wrap for many kinds of
images on a single build. The design decision was made to not use any
conditional compilation code (#ifdef, etc) in the boot wrapper source code.
All of the boot wrapper pieces are buildable at any time regardless of the
kernel configuration. Building all the wrapper bits on every kernel build
also ensures that obscure parts of the wrapper are at the very least compile
tested in a large variety of environments.
The wrapper is adapted for different image types at link time by linking in
just the wrapper bits that are appropriate for the image type. The 'wrapper
script' (found in arch/powerpc/boot/wrapper) is called by the Makefile and
is responsible for selecting the correct wrapper bits for the image type.
The arguments are well documented in the script's comment block, so they
are not repeated here. However, it is worth mentioning that the script
uses the -p (platform) argument as the main method of deciding which wrapper
bits to compile in. Look for the large 'case "$platform" in' block in the
middle of the script. This is also the place where platform specific fixups
can be selected by changing the link order.
In particular, care should be taken when working with cuImages. cuImage
wrapper bits are very board specific and care should be taken to make sure
the target you are trying to build is supported by the wrapper bits.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
PowerPC boot wrapper와 firmware 형식
1-24Copyright는 Secret Lab Technologies Ltd.에 있습니다. PowerPC image target은 kernel image `vmlinux`를 압축하고 boot wrapper로 감싸 system firmware가 사용할 수 있게 합니다. 표준 PowerPC firmware interface가 없기 때문에 boot wrapper는 build해야 하는 image 종류마다 적응할 수 있도록 설계되었습니다.
Boot wrapper source는 `arch/powerpc/boot/`에 있으며 그 directory의 Makefile이 사용할 수 있는 모든 image type target을 제공합니다. 서로 다른 type은 PowerPC platform의 다양한 firmware interface를 지원합니다.
Apple, IBM 등의 general-purpose PowerPC system은 주로 OpenFirmware를 사용하고 embedded hardware는 보통 U-Boot를 사용하지만, 널리 쓰이는 다른 firmware 구현도 있습니다. Firmware interface마다 요구하는 image format이 다릅니다.
`arch/powerpc/boot/Makefile`은 `arch/powerpc/boot/wrapper` script를 사용해 target image를 생성합니다.
Boot image format target
25-92| Target | 용도와 구성 |
|---|---|
| `cuImage.%` | Device tree를 이해하지 못하는 오래된 U-Boot와 호환되는 `uImage`입니다. Boot wrapper, kernel, embedded DTB를 U-Boot uImage format 안에 넣고, wrapper가 과거 `bd_info` structure의 data를 device tree에 채운 뒤 kernel로 jump합니다. `bd_info`의 많은 `#ifdef` 때문에 platform-specific이며, init code는 `arch/powerpc/boot/cuboot.*.c`에 있고 wrapper structure가 board별 올바른 code를 선택합니다. |
| `dtbImage.%` | `zImage`와 비슷하지만 firmware가 DTB를 전달하는 대신 image 안에 embed합니다. Platform에 따라 ELF 또는 flat binary가 됩니다. Device tree 직접 전달 interface가 없는 system에서 사용하며, board firmware에서 data를 꺼내는 platform-specific code가 있다는 점에서 firmware와 전혀 통신하지 않는 `simpleImage`와 다릅니다. PlayStation 3와 PlanetCore firmware 기반 Embedded Planet board가 사용하며 보통 `arch/powerpc/boot/<platform>.c`가 초기화를 담당하고 wrapper script가 이를 override할 수 있습니다. |
| `simpleImage.%` | 특정 firmware interface에 의존하지 않는 compressed flat binary이며 DTB를 embed합니다. RAM의 어느 위치든 load해 jump할 수 있지만 firmware가 configuration data를 kernel에 전달할 수 없으므로 모든 정보를 embedded device tree에 의존합니다. |
| `treeImage.%` | 일부 ppc4xx hardware의 OpenBIOS firmware용 image format이며 DTB를 image 안에 embed합니다. |
| `uImage` | U-Boot native image format입니다. Boot code를 추가하지 않고 compressed `vmlinux`를 uImage data structure로 감쌉니다. Boot 시 device tree를 kernel에 전달할 수 있는 U-Boot가 필요하며, 오래된 U-Boot에서는 대신 `cuImage`를 사용해야 합니다. |
| `zImage.%` | Device tree를 embed하지 않는 형식입니다. OpenFirmware처럼 boot 때 device tree를 제공할 수 있는 firmware interface에 사용하며, 보통 general-purpose PowerPC hardware에 적합합니다. |
Firmware가 DTB를 제공하는지와 board-specific fixup이 필요한지가 target 선택을 결정합니다.
Embedded DTB와 default target
93-105DTB를 embed하는 `simpleImage`, `dtbImage`, `treeImage`, `cuImage`는 모두 `arch/powerpc/boot/dts/`의 file로 device-tree blob을 생성합니다. Makefile은 target 이름에서 올바른 device-tree source를 고릅니다.
예를 들어 `make treeImage.walnut`을 실행하면 build system은 `arch/powerpc/boot/dts/walnut.dts`로 `treeImage.walnut`을 만듭니다.
Special target `zImage`와 `zImage.initrd`는 kernel configuration이 선택한 모든 default image를 build합니다. Boot-wrapper Makefile은 `$image-y` variable에 target을 추가해 default image를 선택하며, 사용할 수 있는 target은 `arch/powerpc/boot/Makefile`에서 확인합니다.
Link-time 조립 방식
106-131`arch/powerpc`는 하나의 `vmlinux` image를 여러 target board에서 boot할 수 있는 multi-platform kernel을 지향합니다. 따라서 boot wrapper도 한 build에서 여러 image type을 감쌀 수 있어야 합니다.
Boot wrapper source에는 `#ifdef` 같은 conditional compilation을 사용하지 않기로 설계했습니다. Kernel configuration과 무관하게 모든 wrapper piece를 언제든 build할 수 있고, 매 kernel build에서 전부 compile하므로 드문 wrapper code도 다양한 environment에서 최소한 compile test를 받습니다.
Image type별 적응은 link time에 필요한 wrapper piece만 연결해서 수행합니다. Makefile이 호출하는 `arch/powerpc/boot/wrapper` script가 image type에 맞는 piece를 고릅니다. Argument는 script comment block에 설명되어 있으며, 주된 선택 기준은 `-p` (`platform`) argument입니다. Script 가운데의 큰 `case "$platform" in` block이 이 결정을 담당하고, link order를 바꾸어 platform-specific fixup도 고를 수 있습니다.
`cuImage`를 다룰 때는 특히 주의해야 합니다. 그 wrapper piece는 board 의존성이 매우 크므로 build하려는 target을 해당 piece가 실제로 지원하는지 확인해야 합니다.
Configuration과 무관하게 compile한 piece를 target별로 link합니다.
요약과 해설
bootwrapper.rst:1-131Firmware가 DTB를 제공하는지, wrapper가 board data를 보정해야 하는지에 따라 `zImage`, `uImage`, `simpleImage`, `dtbImage`, `treeImage`, `cuImage`를 선택합니다. 모든 wrapper piece는 항상 compile하고 target에 필요한 것만 link합니다.